Commit ef76a73e authored by Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer
Browse files

Add a new event to video decoders: 1st frame (since preprocess) decoded

parent 33599a54
...@@ -127,6 +127,8 @@ typedef enum _MSPlayerState MSPlayerState; ...@@ -127,6 +127,8 @@ typedef enum _MSPlayerState MSPlayerState;
/** Interface definitions for video decoders */ /** Interface definitions for video decoders */
#define MS_VIDEO_DECODER_DECODING_ERRORS \ #define MS_VIDEO_DECODER_DECODING_ERRORS \
MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,0) MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,0)
#define MS_VIDEO_DECODER_FIRST_IMAGE_DECODED \
MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,1)
/** Interface definitions for video capture */ /** Interface definitions for video capture */
#define MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION \ #define MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION \
......
...@@ -39,6 +39,7 @@ typedef struct _DecData{ ...@@ -39,6 +39,7 @@ typedef struct _DecData{
uint8_t *bitstream; uint8_t *bitstream;
int bitstream_size; int bitstream_size;
uint64_t last_error_reported_time; uint64_t last_error_reported_time;
bool_t first_image_decoded;
}DecData; }DecData;
static void ffmpeg_init(){ static void ffmpeg_init(){
...@@ -80,6 +81,11 @@ static void dec_init(MSFilter *f){ ...@@ -80,6 +81,11 @@ static void dec_init(MSFilter *f){
f->data=d; f->data=d;
} }
static void dec_preprocess(MSFilter* f) {
DecState *s=(DecState*)f->data;
s->first_image_decoded = FALSE;
}
static void dec_reinit(DecData *d){ static void dec_reinit(DecData *d){
avcodec_close(&d->av_context); avcodec_close(&d->av_context);
dec_open(d); dec_open(d);
...@@ -274,6 +280,10 @@ static void dec_process(MSFilter *f){ ...@@ -274,6 +280,10 @@ static void dec_process(MSFilter *f){
} }
if (got_picture) { if (got_picture) {
ms_queue_put(f->outputs[0],get_as_yuvmsg(f,d,&orig)); ms_queue_put(f->outputs[0],get_as_yuvmsg(f,d,&orig));
if (!s->first_image_decoded) {
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
s->first_image_decoded = TRUE;
}
} }
p+=len; p+=len;
} }
...@@ -318,6 +328,7 @@ MSFilterDesc ms_h264_dec_desc={ ...@@ -318,6 +328,7 @@ MSFilterDesc ms_h264_dec_desc={
.ninputs=1, .ninputs=1,
.noutputs=1, .noutputs=1,
.init=dec_init, .init=dec_init,
.preprocess=dec_preprocess,
.process=dec_process, .process=dec_process,
.uninit=dec_uninit, .uninit=dec_uninit,
.methods=h264_dec_methods .methods=h264_dec_methods
...@@ -335,7 +346,7 @@ MSFilterDesc ms_h264_dec_desc={ ...@@ -335,7 +346,7 @@ MSFilterDesc ms_h264_dec_desc={
1, 1,
1, 1,
dec_init, dec_init,
NULL, dec_preprocess,
dec_process, dec_process,
NULL, NULL,
dec_uninit, dec_uninit,
......
...@@ -45,6 +45,7 @@ typedef struct DecState{ ...@@ -45,6 +45,7 @@ typedef struct DecState{
int dci_size; int dci_size;
uint64_t last_error_reported_time; uint64_t last_error_reported_time;
bool_t snow_initialized; bool_t snow_initialized;
bool_t first_image_decoded;
}DecState; }DecState;
...@@ -129,7 +130,8 @@ static int dec_add_fmtp(MSFilter *f, void *data){ ...@@ -129,7 +130,8 @@ static int dec_add_fmtp(MSFilter *f, void *data){
static void dec_preprocess(MSFilter *f){ static void dec_preprocess(MSFilter *f){
DecState *s=(DecState*)f->data; DecState *s=(DecState*)f->data;
int error; int error;
s->first_image_decoded = FALSE;
if (s->av_context.codec==NULL){ if (s->av_context.codec==NULL){
/* we must know picture size before initializing snow decoder*/ /* we must know picture size before initializing snow decoder*/
if (s->codec!=CODEC_ID_SNOW){ if (s->codec!=CODEC_ID_SNOW){
...@@ -683,6 +685,11 @@ static void dec_process_frame(MSFilter *f, mblk_t *inm){ ...@@ -683,6 +685,11 @@ static void dec_process_frame(MSFilter *f, mblk_t *inm){
mblk_t *om = get_as_yuvmsg(f,s,&orig); mblk_t *om = get_as_yuvmsg(f,s,&orig);
if (om!=NULL) if (om!=NULL)
ms_queue_put(f->outputs[0],om); ms_queue_put(f->outputs[0],om);
if (!s->first_image_decoded) {
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
s->first_image_decoded = TRUE;
}
} }
frame->b_rptr+=len; frame->b_rptr+=len;
} }
......
...@@ -466,6 +466,7 @@ typedef struct DecState { ...@@ -466,6 +466,7 @@ typedef struct DecState {
MSPicture outbuf; MSPicture outbuf;
int yuv_width, yuv_height; int yuv_width, yuv_height;
MSQueue q; MSQueue q;
bool_t first_image_decoded;
} DecState; } DecState;
...@@ -484,11 +485,13 @@ static void dec_init(MSFilter *f) { ...@@ -484,11 +485,13 @@ static void dec_init(MSFilter *f) {
s->yuv_height = 0; s->yuv_height = 0;
s->yuv_msg = 0; s->yuv_msg = 0;
ms_queue_init(&s->q); ms_queue_init(&s->q);
s->first_image_decoded = FALSE;
f->data = s; f->data = s;
} }
static void dec_preprocess(MSFilter* f) { static void dec_preprocess(MSFilter* f) {
DecState *s=(DecState*)f->data;
s->first_image_decoded = FALSE;
} }
static void dec_uninit(MSFilter *f) { static void dec_uninit(MSFilter *f) {
...@@ -599,6 +602,11 @@ static void dec_process(MSFilter *f) { ...@@ -599,6 +602,11 @@ static void dec_process(MSFilter *f) {
} }
} }
ms_queue_put(f->outputs[0], dupmsg(s->yuv_msg)); ms_queue_put(f->outputs[0], dupmsg(s->yuv_msg));
if (!s->first_image_decoded) {
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
s->first_image_decoded = TRUE;
}
} }
freemsg(m); freemsg(m);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment