//
enum codec_api_type {
- CODEC_INIT = 0,
- CODEC_DECODE_VIDEO,
- CODEC_ENCODE_VIDEO,
- CODEC_DECODE_AUDIO,
- CODEC_ENCODE_AUDIO,
- CODEC_PICTURE_COPY,
- CODEC_DEINIT,
- CODEC_FLUSH_BUFFERS,
- CODEC_DECODE_VIDEO_AND_PICTURE_COPY,
+ INIT = 0,
+ DECODE_VIDEO,
+ ENCODE_VIDEO,
+ DECODE_AUDIO,
+ ENCODE_AUDIO,
+ PICTURE_COPY,
+ DEINIT,
+ FLUSH_BUFFERS,
+ DECODE_VIDEO_AND_PICTURE_COPY,
};
enum codec_type {
AVPacket *avpkt;
};
- // for audio encoder
+ // for audio decoder
struct {
bool resampled;
int32_t out_sample_fmt;
QTAILQ_HEAD_INITIALIZER(codec_rq);
// codec functions
-static bool codec_init(MaruBrillCodecState *, int, void *);
-static bool codec_deinit(MaruBrillCodecState *, int, void *);
-static bool codec_decode_video(MaruBrillCodecState *, int, void *);
-static bool codec_encode_video(MaruBrillCodecState *, int, void *);
-static bool codec_decode_audio(MaruBrillCodecState *, int, void *);
-static bool codec_encode_audio(MaruBrillCodecState *, int, void *);
-static bool codec_picture_copy(MaruBrillCodecState *, int, void *);
-static bool codec_flush_buffers(MaruBrillCodecState *, int, void *);
-static bool codec_decode_video_and_picture_copy(MaruBrillCodecState *, int, void *);
+static bool init(MaruBrillCodecState *, int, void *);
+static bool deinit(MaruBrillCodecState *, int, void *);
+static bool decode_video(MaruBrillCodecState *, int, void *);
+static bool encode_video(MaruBrillCodecState *, int, void *);
+static bool decode_audio(MaruBrillCodecState *, int, void *);
+static bool encode_audio(MaruBrillCodecState *, int, void *);
+static bool picture_copy(MaruBrillCodecState *, int, void *);
+static bool flush_buffers(MaruBrillCodecState *, int, void *);
+static bool decode_video_and_picture_copy(MaruBrillCodecState *, int, void *);
typedef bool (*CodecFuncEntry)(MaruBrillCodecState *, int, void *);
static CodecFuncEntry codec_func_handler[] = {
- codec_init,
- codec_decode_video,
- codec_encode_video,
- codec_decode_audio,
- codec_encode_audio,
- codec_picture_copy,
- codec_deinit,
- codec_flush_buffers,
- codec_decode_video_and_picture_copy,
+ init,
+ decode_video,
+ encode_video,
+ decode_audio,
+ encode_audio,
+ picture_copy,
+ deinit,
+ flush_buffers,
+ decode_video_and_picture_copy,
};
// default data handler
elem->param_buf = ioparam;
switch(ioparam->api_index) {
- case CODEC_INIT:
- case CODEC_DECODE_VIDEO:
- case CODEC_ENCODE_VIDEO:
- case CODEC_DECODE_AUDIO:
- case CODEC_ENCODE_AUDIO:
- case CODEC_DECODE_VIDEO_AND_PICTURE_COPY:
+ case INIT:
+ case DECODE_VIDEO:
+ case ENCODE_VIDEO:
+ case DECODE_AUDIO:
+ case ENCODE_AUDIO:
+ case DECODE_VIDEO_AND_PICTURE_COPY:
data_buf = brillcodec_store_inbuf((uint8_t *)s->vaddr, ioparam);
break;
- case CODEC_PICTURE_COPY:
- case CODEC_DEINIT:
- case CODEC_FLUSH_BUFFERS:
+ case PICTURE_COPY:
+ case DEINIT:
+ case FLUSH_BUFFERS:
default:
TRACE("no buffer from guest\n");
break;
qemu_mutex_lock(&s->context_mutex);
- if (ioparam->api_index != CODEC_INIT) {
+ if (ioparam->api_index != INIT) {
if (!CONTEXT(s, ioparam->ctx_index)->opened_context) {
INFO("abandon api %d for context %d\n",
ioparam->api_index, ioparam->ctx_index);
qemu_mutex_lock(&s->threadpool.mutex);
if (CONTEXT(s, ctx_id)->opened_context) {
// qemu_mutex_unlock(&s->threadpool.mutex);
- codec_deinit(s, ctx_id, NULL);
+ deinit(s, ctx_id, NULL);
// qemu_mutex_lock(&s->threadpool.mutex);
}
CONTEXT(s, ctx_id)->occupied_context = false;
// FLUSH BUFFERS
//
-static bool codec_flush_buffers(MaruBrillCodecState *s, int ctx_id, void *data_buf)
+static bool flush_buffers(MaruBrillCodecState *s, int ctx_id, void *data_buf)
{
AVCodecContext *avctx = NULL;
bool ret = true;
return len;
}
-static bool codec_decode_video_common(MaruBrillCodecState *s, int ctx_id,
+static bool decode_video_common(MaruBrillCodecState *s, int ctx_id,
void *data_buf, bool copy_picture)
{
AVCodecContext *avctx = NULL;
return true;
}
-static bool codec_decode_video(MaruBrillCodecState *s, int ctx_id, void *data_buf)
+static bool decode_video(MaruBrillCodecState *s, int ctx_id, void *data_buf)
{
- return codec_decode_video_common(s, ctx_id, data_buf, false);
+ return decode_video_common(s, ctx_id, data_buf, false);
}
-static bool codec_decode_video_and_picture_copy(MaruBrillCodecState *s, int ctx_id, void *data_buf)
+static bool decode_video_and_picture_copy(MaruBrillCodecState *s, int ctx_id, void *data_buf)
{
- return codec_decode_video_common(s, ctx_id, data_buf, true);
+ return decode_video_common(s, ctx_id, data_buf, true);
}
-static bool codec_picture_copy(MaruBrillCodecState *s, int ctx_id, void *elem)
+static bool picture_copy(MaruBrillCodecState *s, int ctx_id, void *elem)
{
DataContainer *dc = g_malloc0(sizeof(DataContainer));
return true;
}
-static bool codec_encode_video(MaruBrillCodecState *s, int ctx_id, void *data_buf)
+static bool encode_video(MaruBrillCodecState *s, int ctx_id, void *data_buf)
{
AVCodecContext *avctx = NULL;
AVFrame *pict = NULL;
* audios sink cannot handle planar format, so it is required
* to resample audio buffer into linear format.
*/
-static bool codec_decode_audio(MaruBrillCodecState *s, int ctx_id, void *data_buf)
+static bool decode_audio(MaruBrillCodecState *s, int ctx_id, void *data_buf)
{
AVCodecContext *avctx;
AVPacket avpkt;
return true;
}
-static bool codec_encode_audio(MaruBrillCodecState *s, int ctx_id, void *data_buf)
+static bool encode_audio(MaruBrillCodecState *s, int ctx_id, void *data_buf)
{
AVCodecContext *avctx = NULL;
AVPacket avpkt;
return parser;
}
-static bool codec_init(MaruBrillCodecState *s, int ctx_id, void *data_buf)
+static bool init(MaruBrillCodecState *s, int ctx_id, void *data_buf)
{
AVCodecContext *avctx = NULL;
AVCodec *codec = NULL;
return true;
}
-static bool codec_deinit(MaruBrillCodecState *s, int ctx_id, void *data_buf)
+static bool deinit(MaruBrillCodecState *s, int ctx_id, void *data_buf)
{
AVCodecContext *avctx = NULL;
AVFrame *frame = NULL;