diff --git a/contrib/media/fplay/fplay.h b/contrib/media/fplay/fplay.h index 0c55d82873..9e05952923 100644 --- a/contrib/media/fplay/fplay.h +++ b/contrib/media/fplay/fplay.h @@ -133,6 +133,8 @@ struct vstate AVCodecContext *aCtx; /* audio decoder context */ AVCodec *vCodec; /* video codec */ AVCodec *aCodec; /* audio codec */ + enum AVCodecID codec_id; + int codec_profile; char *input_file; char *input_name; int vStream; /* video stream index */ diff --git a/contrib/media/fplay/vaapi.c b/contrib/media/fplay/vaapi.c index c247928099..8cb3111640 100644 --- a/contrib/media/fplay/vaapi.c +++ b/contrib/media/fplay/vaapi.c @@ -398,14 +398,32 @@ static enum PixelFormat get_format(struct AVCodecContext *avctx, VAProfile profile = avctx->profile; enum AVCodecID codec = avctx->codec_id; - printf("%s codec %d profile %x\n", __FUNCTION__,avctx->codec_id, avctx->profile); - if (codec == AV_CODEC_ID_H264) { if(profile == FF_PROFILE_H264_BASELINE) profile = FF_PROFILE_H264_CONSTRAINED_BASELINE; }; + if(avctx->hwaccel_context != NULL && + (vst->codec_id != codec || + vst->codec_profile != profile)) + { + struct decoder* decoder = vst->decoder; + + printf("\n%s codec changed!!!\n" + "old id %d profile %x new id %d profile %x\n", + __FUNCTION__, vst->codec_id, vst->codec_profile, + codec, profile); + + for(int i = 0; i < decoder->nframes; i++) + { + vframe_t *vframe = &decoder->vframes[i]; + vframe->format = AV_PIX_FMT_NONE; + }; + } + + printf("\n%s codec %d profile %x\n", __FUNCTION__,avctx->codec_id, avctx->profile); + for (int i = 0; fmt[i] != PIX_FMT_NONE; i++) { if (fmt[i] != AV_PIX_FMT_VAAPI_VLD) @@ -420,6 +438,8 @@ static enum PixelFormat get_format(struct AVCodecContext *avctx, if (vaapi_init_decoder(vst, profile, VAEntrypointVLD, avctx->width, avctx->height) == 0) { avctx->hwaccel_context = v_context; + vst->codec_id = codec; + vst->codec_profile = profile; printf("%s format: %x\n",__FUNCTION__, fmt[i]); return fmt[i]; } @@ -458,9 +478,6 @@ static int get_buffer2(AVCodecContext *avctx, AVFrame *pic, int flags) return 0; } -struct vaapi_context va_context_storage; - - #define EGL_TEXTURE_Y_U_V_WL 0x31D7 #define EGL_TEXTURE_Y_UV_WL 0x31D8