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;
/** Interface definitions for video decoders */
#define MS_VIDEO_DECODER_DECODING_ERRORS \
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 */
#define MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION \
......
......@@ -39,6 +39,7 @@ typedef struct _DecData{
uint8_t *bitstream;
int bitstream_size;
uint64_t last_error_reported_time;
bool_t first_image_decoded;
}DecData;
static void ffmpeg_init(){
......@@ -80,6 +81,11 @@ static void dec_init(MSFilter *f){
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){
avcodec_close(&d->av_context);
dec_open(d);
......@@ -274,6 +280,10 @@ static void dec_process(MSFilter *f){
}
if (got_picture) {
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;
}
......@@ -318,6 +328,7 @@ MSFilterDesc ms_h264_dec_desc={
.ninputs=1,
.noutputs=1,
.init=dec_init,
.preprocess=dec_preprocess,
.process=dec_process,
.uninit=dec_uninit,
.methods=h264_dec_methods
......@@ -335,7 +346,7 @@ MSFilterDesc ms_h264_dec_desc={
1,
1,
dec_init,
NULL,
dec_preprocess,
dec_process,
NULL,
dec_uninit,
......
......@@ -45,6 +45,7 @@ typedef struct DecState{
int dci_size;
uint64_t last_error_reported_time;
bool_t snow_initialized;
bool_t first_image_decoded;
}DecState;
......@@ -129,6 +130,7 @@ static int dec_add_fmtp(MSFilter *f, void *data){
static void dec_preprocess(MSFilter *f){
DecState *s=(DecState*)f->data;
int error;
s->first_image_decoded = FALSE;
if (s->av_context.codec==NULL){
/* we must know picture size before initializing snow decoder*/
......@@ -683,6 +685,11 @@ static void dec_process_frame(MSFilter *f, mblk_t *inm){
mblk_t *om = get_as_yuvmsg(f,s,&orig);
if (om!=NULL)
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;
}
......
......@@ -466,6 +466,7 @@ typedef struct DecState {
MSPicture outbuf;
int yuv_width, yuv_height;
MSQueue q;
bool_t first_image_decoded;
} DecState;
......@@ -484,11 +485,13 @@ static void dec_init(MSFilter *f) {
s->yuv_height = 0;
s->yuv_msg = 0;
ms_queue_init(&s->q);
s->first_image_decoded = FALSE;
f->data = s;
}
static void dec_preprocess(MSFilter* f) {
DecState *s=(DecState*)f->data;
s->first_image_decoded = FALSE;
}
static void dec_uninit(MSFilter *f) {
......@@ -599,6 +602,11 @@ static void dec_process(MSFilter *f) {
}
}
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);
}
......
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