diff mbox series

[FFmpeg-devel] hevc/sei: return INVALIDDATA when a referenced SPS is not available

Message ID 20240830112033.227-1-h.leppkes@gmail.com
State New
Headers show
Series [FFmpeg-devel] hevc/sei: return INVALIDDATA when a referenced SPS is not available | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Hendrik Leppkes Aug. 30, 2024, 11:20 a.m. UTC
The code previously returned ENOMEM, despite this not being an
allocation problem, but rather a bitstream problem referring to data not
currently available.

Fixes playback of such streams, as it allows further processing of NAL
units after skipping the broken SEI NAL.
---
 libavcodec/hevc/sei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Ekström Aug. 30, 2024, 9:09 p.m. UTC | #1
On Fri, Aug 30, 2024 at 8:40 PM Hendrik Leppkes <h.leppkes@gmail.com> wrote:
>
> The code previously returned ENOMEM, despite this not being an
> allocation problem, but rather a bitstream problem referring to data not
> currently available.
>
> Fixes playback of such streams, as it allows further processing of NAL
> units after skipping the broken SEI NAL.
> ---
>  libavcodec/hevc/sei.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
> index e39ac0c38a..b55ba71a8d 100644
> --- a/libavcodec/hevc/sei.c
> +++ b/libavcodec/hevc/sei.c
> @@ -56,7 +56,7 @@ static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb,
>      const HEVCSPS *sps = ps->sps_list[s->active_seq_parameter_set_id];
>
>      if (!sps)
> -        return(AVERROR(ENOMEM));
> +        return AVERROR_INVALIDDATA;
>
>      if (sps->vui.frame_field_info_present_flag) {
>          int pic_struct = get_bits(gb, 4);
> --
> 2.42.0.windows.2

LGTM.

Verified that FATE still passes and that the sample linked in
https://github.com/mpv-player/mpv/issues/14764 once again decodes.

after 90fc331b0fc6f7d9c31f9e6d543102ba7fe02daf in master:
Stream #0:0: Video: hevc, 1 reference frame, none, 3840x1920
after applying this patch:
Stream #0:0: Video: hevc (Main 10), 1 reference frame, yuv420p10le(tv,
left), 3840x1920

(in addition to various additional NAL units getting parsed and much
less warnings being logged)

Jan
Hendrik Leppkes Sept. 2, 2024, 5:58 p.m. UTC | #2
On Fri, Aug 30, 2024 at 11:09 PM Jan Ekström <jeebjp@gmail.com> wrote:
>
> On Fri, Aug 30, 2024 at 8:40 PM Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> >
> > The code previously returned ENOMEM, despite this not being an
> > allocation problem, but rather a bitstream problem referring to data not
> > currently available.
> >
> > Fixes playback of such streams, as it allows further processing of NAL
> > units after skipping the broken SEI NAL.
> > ---
> >  libavcodec/hevc/sei.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
> > index e39ac0c38a..b55ba71a8d 100644
> > --- a/libavcodec/hevc/sei.c
> > +++ b/libavcodec/hevc/sei.c
> > @@ -56,7 +56,7 @@ static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb,
> >      const HEVCSPS *sps = ps->sps_list[s->active_seq_parameter_set_id];
> >
> >      if (!sps)
> > -        return(AVERROR(ENOMEM));
> > +        return AVERROR_INVALIDDATA;
> >
> >      if (sps->vui.frame_field_info_present_flag) {
> >          int pic_struct = get_bits(gb, 4);
> > --
> > 2.42.0.windows.2
>
> LGTM.
>
> Verified that FATE still passes and that the sample linked in
> https://github.com/mpv-player/mpv/issues/14764 once again decodes.
>

Will apply tomorrow if there are no further comments.

- Hendrik
diff mbox series

Patch

diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
index e39ac0c38a..b55ba71a8d 100644
--- a/libavcodec/hevc/sei.c
+++ b/libavcodec/hevc/sei.c
@@ -56,7 +56,7 @@  static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb,
     const HEVCSPS *sps = ps->sps_list[s->active_seq_parameter_set_id];
 
     if (!sps)
-        return(AVERROR(ENOMEM));
+        return AVERROR_INVALIDDATA;
 
     if (sps->vui.frame_field_info_present_flag) {
         int pic_struct = get_bits(gb, 4);