1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/*
* Emulator
*
* Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* KiTae Kim <kt920.kim@samsung.com>
* SeokYeon Hwang <syeon.hwang@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* First, include the header file for the plugin, to bring in the
* object definition and other useful things.
*/
/*
*
* Contributors:
* - S-Core Co., Ltd
*
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
/* FFMPEG API */
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
// #define EMULCODEC_DEBUG
// #define CODEC_HOST
#ifdef EMULCODEC_DEBUG
#define GST_CODEC_LOG(fmt, ...) \
fprintf(stdout, "[%s][%d]" fmt, __func__, __LINE__, ##__VA_ARGS__);
#else
#define GST_CODEC_LOG(fmt, ...) ((void)0);
#endif
typedef struct _CodecParam {
uint32_t func_num;
uint32_t in_args_num;
uint32_t in_args[20];
uint32_t ret_args;
} CodecParam;
typedef struct _ParserBuf {
uint8_t *buf;
uint32_t size;
} ParserBuf;
#define PARAM_INIT(varCodec, defCodec) \
memset(&varCodec, 0x00, sizeof(defCodec))
enum {
EMUL_AV_REGISTER_ALL = 1,
EMUL_AVCODEC_OPEN,
EMUL_AVCODEC_CLOSE,
EMUL_AVCODEC_ALLOC_CONTEXT,
EMUL_AVCODEC_ALLOC_FRAME,
EMUL_AV_FREE_CONTEXT,
EMUL_AV_FREE_PICTURE,
EMUL_AV_FREE_PALCTRL,
EMUL_AV_FREE_EXTRADATA,
EMUL_AVCODEC_FLUSH_BUFFERS,
EMUL_AVCODEC_DECODE_VIDEO,
EMUL_AVCODEC_ENCODE_VIDEO,
EMUL_AV_PICTURE_COPY,
EMUL_AV_PARSER_INIT,
EMUL_AV_PARSER_PARSE,
EMUL_AV_PARSER_CLOSE,
};
int emul_open_codecdev (void);
void emul_close_codecdev (void);
/* FFMPEG API */
void emul_av_register_all (void);
int emul_avcodec_open (AVCodecContext *avctx, AVCodec *codec);
int emul_avcodec_close (AVCodecContext *avctx);
void emul_avcodec_alloc_frame (void);
void emul_avcodec_alloc_context (void);
void emul_av_free_context (void);
void emul_av_free_picture (void);
void emul_av_free_palctrl (void);
void emul_av_free_extradata (void);
void emul_avcodec_flush_buffers (AVCodecContext *ctx);
int emul_avcodec_decode_video (AVCodecContext *ctx, AVFrame *frame,
int *got_picture_ptr, uint8_t *buf, int buf_size);
int emul_avcodec_encode_video (AVCodecContext *ctx, uint8_t *buf,
int buf_size, const AVFrame *pict, uint8_t *pict_buf);
void emul_av_picture_copy(AVPicture *dst, const AVPicture *src,
enum PixelFormat pix_fmt, int width, int height);
void emul_av_parser_init (void);
int emul_av_parser_parse (AVCodecParserContext *s, AVCodecContext *ctx,
uint8_t **outbuf, int *outbuf_size,
const uint8_t *buf, int buf_size,
int64_t pts, int64_t dts);
void emul_av_parser_close (void);
|