summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprasanth kamuju <prasanth.kamuju@linaro.org>2014-07-17 13:31:32 +0530
committerprasanth kamuju <prasanth.kamuju@linaro.org>2014-07-17 13:31:32 +0530
commitd1b3931af7ba2171623d499e8b6005bd68017896 (patch)
tree4a74191e961acfce7e23b6db9a0da00bd20fc00d
parent34db21368f6695d3883415a82c31e05684a8335a (diff)
vidctest: Parse header info from MPEG4 container file
Parse the header info from input MPEG4 container file, divide the bit stream and then pass it to driver frame by frame for decode.
-rwxr-xr-xdecodertest/decoder_driver_test.c59
1 files changed, 41 insertions, 18 deletions
diff --git a/decodertest/decoder_driver_test.c b/decodertest/decoder_driver_test.c
index acc202a..c3f7859 100755
--- a/decodertest/decoder_driver_test.c
+++ b/decodertest/decoder_driver_test.c
@@ -46,7 +46,7 @@ static int total_frames = 0;
static unsigned int header_code = 0,file_type=0;
static pthread_mutex_t read_lock;
int reconfig =0;
-int count =0;
+
static unsigned int read_frame ( unsigned char *dataptr,unsigned int length,
FILE * inputBufferFile
);
@@ -190,11 +190,8 @@ int main (int argc, char **argv)
int size,width=0,height=0;
AVPacket pk = {};
- printf("\nopen_stream Entered:\n");
- if (cc->codec_id != CODEC_ID_H264) {
- printf("could not open '%s': unsupported codec %d", file_name, cc->codec_id);
- return -1;
- }
+ printf("\nopen_stream Entered coded_id : %d\n",cc->codec_id);
+
if (cc->extradata && cc->extradata_size > 0 && cc->extradata[0] == 1) {
printf("initializing bitstream filter");
bsf = av_bitstream_filter_init("h264_mp4toannexb");
@@ -212,12 +209,23 @@ int main (int argc, char **argv)
decoder_context->demux_data->st = st;
decoder_context->demux_data->bsf = bsf;
- if(cc->codec_id == 28)
+ if(cc->codec_id == AV_CODEC_ID_H264)
{
DEBUG_PRINT("\n codec format VDEC_CODECTYPE_H264 ");
decoder_context->decoder_format = VDEC_CODECTYPE_H264;
Codec_type = VDEC_CODECTYPE_H264;
}
+ else if(cc->codec_id == AV_CODEC_ID_MPEG4)
+ {
+ DEBUG_PRINT("\n codec format MPEG4 ");
+ decoder_context->decoder_format = VDEC_CODECTYPE_MPEG4;
+ Codec_type = VDEC_CODECTYPE_MPEG4;
+ }
+ else
+ {
+ DEBUG_PRINT("\n codec format not suported ");
+ return -1;
+ }
size = cc->width * cc->height;
printf("\nopen_stream cc->codec_id:%d\n",cc->codec_id);
printf("\nopen_stream width:%d , height = %d\n",cc->width,cc->height);
@@ -325,12 +333,19 @@ int main (int argc, char **argv)
pthread_join( decoder_context->videothread_id, NULL);
DEBUG_PRINT("\n Threads are finished with proce\n");
- printf("\nopen_stream cc->codec_id:%d\n",decoder_context->demux_data->cc->codec_id);
- printf("\nopen_stream width:%d , height = %d\n",decoder_context->demux_data->cc->width,decoder_context->demux_data->cc->height);
+ if(decoder_context->demux_data->cc->codec_id == AV_CODEC_ID_H264)
+ {
+ DEBUG_PRINT("\n >>>>>>> codec format VDEC_CODECTYPE_H264 ");
+ }
+ else if(decoder_context->demux_data->cc->codec_id == AV_CODEC_ID_MPEG4)
+ {
+ DEBUG_PRINT("\n >>>>>>> codec format MPEG4 ");
+ }
+ printf("\n >>>>>>> open_stream width:%d , height = %d\n",decoder_context->demux_data->cc->width,decoder_context->demux_data->cc->height);
if (error != -1)
{
- DEBUG_PRINT ("\n\n Total Number of frames decoded %d\n",total_frames);
+ DEBUG_PRINT ("\n >>>>>>> Total Number of frames decoded %d\n",total_frames);
/* Decoding is completed,now we need to de-initialize the decoder */
DEBUG_PRINT("\n De-init the decoder Enter");
if ((deinit_decoder (decoder_context) == -1))
@@ -349,7 +364,7 @@ int main (int argc, char **argv)
{
fclose (decoder_context->outputBufferFile);
}
- DEBUG_PRINT("\n input and output files are closed video_decoder is going to close \n");
+ DEBUG_PRINT(" input and output files are closed video_decoder is going to close ");
close (decoder_context->video_driver_fd);
DEBUG_PRINT("\n free the decoder_context and return \n");
free(decoder_context);
@@ -578,7 +593,7 @@ int free_buffer ( enum vdec_buffer buffer_dir,
decode_context->h264_mv.ion_alloc_data.handle = NULL;
decode_context->h264_mv.fd_ion_data.fd = -1;
- DEBUG_PRINT("Cleaning H264_MV buffer of size %d",h264_mv_buff.size);
+// DEBUG_PRINT(" Cleaning H264_MV buffer of size %d",h264_mv_buff.size);
h264_mv_buff.pmem_fd = -1;
h264_mv_buff.offset = 0;
h264_mv_buff.size = 0;
@@ -887,8 +902,17 @@ int start_decoding (struct video_decoder_context *decode_context)
/* read data from container file */
if(file_type == 1)
{
+ /*For MPEG, we need to send the header to video driver */
+ if(decode_context->decoder_format = VDEC_CODECTYPE_MPEG4)
+ {
+ memcpy(decode_context->ptr_inputbuffer [i].bufferaddr,decode_context->demux_data->cc->extradata,decode_context->demux_data->cc->extradata_size);
+ data_len = decode_context->demux_data->cc->extradata_size;
+ }
+ else if(decode_context->decoder_format = VDEC_CODECTYPE_H264)
+ {
data_len = read_frame_from_container(decode_context->ptr_inputbuffer [i].bufferaddr,\
decode_context->ptr_inputbuffer [i].buffer_len,decode_context->demux_data);
+ }
}
else if(file_type == 2) /* read data from bitstream */
@@ -1005,7 +1029,7 @@ int deinit_decoder (struct video_decoder_context *init_decode)
pthread_mutex_destroy(&init_decode->queue_context.mutex);
pthread_mutex_destroy (&read_lock);
- DEBUG_PRINT("\n all threads are closed");
+ DEBUG_PRINT("\n all threads are closed\n");
return 1;
}
int vdec_alloc_h264_mv(void *context)
@@ -1479,8 +1503,7 @@ static unsigned int read_frame_from_container(unsigned char *dataptr, unsigned i
int size = demux_ptr->cc->width * demux_ptr->cc->height;
while (!av_read_frame(demux_ptr->afc, &pk)) {
- count++;
- if (pk.stream_index == demux_ptr->st->index) {
+ if (pk.stream_index == demux_ptr->st->index) {
uint8_t *buf;
int bufsize;
if (demux_ptr->bsf) {
@@ -1488,9 +1511,9 @@ static unsigned int read_frame_from_container(unsigned char *dataptr, unsigned i
ret = av_bitstream_filter_filter(demux_ptr->bsf, demux_ptr->cc,
NULL, &buf, &bufsize, pk.data, pk.size, 0);
if (ret < 0) {
- printf("bsf error: %d", ret);
- return 0;
- }
+ printf("bsf error: %d", ret);
+ return 0;
+ }
} else {
buf = pk.data;
bufsize = pk.size;