Re: [FFmpeg-devel] [PATCH] avcodec/hevc_ps: Remove dead code in vps_id check

2019-09-21 Thread Andriy Gelman
On Sun, 22. Sep 00:44, Carl Eugen Hoyos wrote:
> Am Sa., 21. Sept. 2019 um 04:06 Uhr schrieb Andriy Gelman
> :
> >
> > From: Andriy Gelman 
> >
> > Since reading 4 bits always returns a value in the range [0, 15], the
> > check for vps_id >= HEVC_MAX_VPS_COUNT, where HEVC_MAX_VPS_COUNT = 16, is 
> > redudant.
> > ---
> >  libavcodec/hevc_ps.c | 12 ++--
> >  1 file changed, 2 insertions(+), 10 deletions(-)
> >
> > diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> > index abf08b919b..498467730b 100644
> > --- a/libavcodec/hevc_ps.c
> > +++ b/libavcodec/hevc_ps.c
> > @@ -447,11 +447,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, 
> > AVCodecContext *avctx,
> >  }
> >  memcpy(vps->data, gb->buffer, vps->data_size);
> >
> > -vps_id = get_bits(gb, 4);
> > -if (vps_id >= HEVC_MAX_VPS_COUNT) {
> > -av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
> > -goto err;
> > -}
> > +vps_id = get_bits(gb, 4); // vps_id in [0, HEVC_MAX_VPS_COUNT-1] so no 
> > check needed
> >
> >  if (get_bits(gb, 2) != 3) { // vps_reserved_three_2bits
> >  av_log(avctx, AV_LOG_ERROR, "vps_reserved_three_2bits is not 
> > three\n");
> > @@ -882,11 +878,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
> > unsigned int *sps_id,
> >
> >  // Coded parameters
> >
> > -sps->vps_id = get_bits(gb, 4);
> > -if (sps->vps_id >= HEVC_MAX_VPS_COUNT) {
> > -av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", 
> > sps->vps_id);
> > -return AVERROR_INVALIDDATA;
> > -}
> > +sps->vps_id = get_bits(gb, 4); // sps->vps_id in [0, 
> > HEVC_MAX_VPS_COUNT-1] so no check needed
> 
> The comments look unneeded.

ok, I removed and sent updated version.

Thanks,
-- 
Andriy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/hevc_ps: Remove dead code in vps_id check

2019-09-21 Thread Carl Eugen Hoyos
Am Sa., 21. Sept. 2019 um 04:06 Uhr schrieb Andriy Gelman
:
>
> From: Andriy Gelman 
>
> Since reading 4 bits always returns a value in the range [0, 15], the
> check for vps_id >= HEVC_MAX_VPS_COUNT, where HEVC_MAX_VPS_COUNT = 16, is 
> redudant.
> ---
>  libavcodec/hevc_ps.c | 12 ++--
>  1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index abf08b919b..498467730b 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -447,11 +447,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, 
> AVCodecContext *avctx,
>  }
>  memcpy(vps->data, gb->buffer, vps->data_size);
>
> -vps_id = get_bits(gb, 4);
> -if (vps_id >= HEVC_MAX_VPS_COUNT) {
> -av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
> -goto err;
> -}
> +vps_id = get_bits(gb, 4); // vps_id in [0, HEVC_MAX_VPS_COUNT-1] so no 
> check needed
>
>  if (get_bits(gb, 2) != 3) { // vps_reserved_three_2bits
>  av_log(avctx, AV_LOG_ERROR, "vps_reserved_three_2bits is not 
> three\n");
> @@ -882,11 +878,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
> unsigned int *sps_id,
>
>  // Coded parameters
>
> -sps->vps_id = get_bits(gb, 4);
> -if (sps->vps_id >= HEVC_MAX_VPS_COUNT) {
> -av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", 
> sps->vps_id);
> -return AVERROR_INVALIDDATA;
> -}
> +sps->vps_id = get_bits(gb, 4); // sps->vps_id in [0, 
> HEVC_MAX_VPS_COUNT-1] so no check needed

The comments look unneeded.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/hevc_ps: Remove dead code in vps_id check

2019-09-20 Thread Andriy Gelman
From: Andriy Gelman 

Since reading 4 bits always returns a value in the range [0, 15], the
check for vps_id >= HEVC_MAX_VPS_COUNT, where HEVC_MAX_VPS_COUNT = 16, is 
redudant.
---
 libavcodec/hevc_ps.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index abf08b919b..498467730b 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -447,11 +447,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, 
AVCodecContext *avctx,
 }
 memcpy(vps->data, gb->buffer, vps->data_size);
 
-vps_id = get_bits(gb, 4);
-if (vps_id >= HEVC_MAX_VPS_COUNT) {
-av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
-goto err;
-}
+vps_id = get_bits(gb, 4); // vps_id in [0, HEVC_MAX_VPS_COUNT-1] so no 
check needed
 
 if (get_bits(gb, 2) != 3) { // vps_reserved_three_2bits
 av_log(avctx, AV_LOG_ERROR, "vps_reserved_three_2bits is not three\n");
@@ -882,11 +878,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 
 // Coded parameters
 
-sps->vps_id = get_bits(gb, 4);
-if (sps->vps_id >= HEVC_MAX_VPS_COUNT) {
-av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", sps->vps_id);
-return AVERROR_INVALIDDATA;
-}
+sps->vps_id = get_bits(gb, 4); // sps->vps_id in [0, HEVC_MAX_VPS_COUNT-1] 
so no check needed
 
 if (vps_list && !vps_list[sps->vps_id]) {
 av_log(avctx, AV_LOG_ERROR, "VPS %d does not exist\n",
-- 
2.23.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".