On Tue, 21 May 2013 10:55:11 +0200, Janne Grunau <[email protected]> wrote:
> The decoder did not start predicted frames with missing references but
> called the end of frame handling on them anyway. This caused an
> assertion in the VA API HW accelorator since it tried to render a
> picture with uninitialized buffers.
> ---
> libavcodec/mpeg12dec.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> index 6751864..07de65d 100644
> --- a/libavcodec/mpeg12dec.c
> +++ b/libavcodec/mpeg12dec.c
> @@ -2059,14 +2059,14 @@ static int decode_chunks(AVCodecContext *avctx,
> const uint8_t *buf_ptr = buf;
> const uint8_t *buf_end = buf + buf_size;
> int ret, input_size;
> - int last_code = 0;
> + int last_code = 0, skip_frame = 0;
>
> for (;;) {
> /* find next start code */
> uint32_t start_code = -1;
> buf_ptr = avpriv_find_start_code(buf_ptr, buf_end, &start_code);
> if (start_code > 0x1ff) {
> - if (s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <=
> AVDISCARD_DEFAULT) {
> + if (!skip_frame) {
> if (HAVE_THREADS && (avctx->active_thread_type &
> FF_THREAD_SLICE)) {
> int i;
>
> @@ -2210,20 +2210,27 @@ static int decode_chunks(AVCodecContext *avctx,
> if (s2->last_picture_ptr == NULL) {
> /* Skip B-frames if we do not have reference frames and gop
> is not closed */
> if (s2->pict_type == AV_PICTURE_TYPE_B) {
> - if (!s->closed_gop)
> + if (!s->closed_gop) {
> + skip_frame = 1;
> break;
> + }
> }
> }
> if (s2->pict_type == AV_PICTURE_TYPE_I)
> s->sync=1;
> if (s2->next_picture_ptr == NULL) {
> /* Skip P-frames if we do not have a reference frame or we
> have an invalid header. */
> - if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync)
> break;
> + if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) {
> + skip_frame = 1;
> + break;
Weird indent.
> + }
> }
> if ((avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type
> == AV_PICTURE_TYPE_B) ||
> (avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type
> != AV_PICTURE_TYPE_I) ||
> - avctx->skip_frame >= AVDISCARD_ALL)
> + avctx->skip_frame >= AVDISCARD_ALL) {
> + skip_frame = 1;
> break;
> + }
>
> if (!s->mpeg_enc_ctx_allocated)
> break;
> @@ -2241,6 +2248,7 @@ static int decode_chunks(AVCodecContext *avctx,
> }
>
> if (s2->first_slice) {
> + skip_frame = 0;
> s2->first_slice = 0;
> if (mpeg_field_start(s2, buf, buf_size) < 0)
> return -1;
Otherwise looks fine.
--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel