diff mbox series

[FFmpeg-devel,09/12] avformat/hevc: Defer initializations in ff_isom_write_hvcc()

Message ID 20200124224833.17579-3-andreas.rheinhardt@gmail.com
State Accepted
Commit 1884d887bae30d702ac4d059fe80646e8d2f294b
Headers show
Series [FFmpeg-devel,1/6] avformat/matroskaenc: Check for reformatting errors | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt Jan. 24, 2020, 10:48 p.m. UTC
Saves initialization of an HEVCDecoderConfigurationRecord when
the data is already in ISOBMFF-format or if it is plainly invalid.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/hevc.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

Andreas Rheinhardt June 30, 2020, 6:59 p.m. UTC | #1
Andreas Rheinhardt:
> Saves initialization of an HEVCDecoderConfigurationRecord when
> the data is already in ISOBMFF-format or if it is plainly invalid.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/hevc.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/libavformat/hevc.c b/libavformat/hevc.c
> index a4e53bc4ab..616e9ed49a 100644
> --- a/libavformat/hevc.c
> +++ b/libavformat/hevc.c
> @@ -1070,29 +1070,27 @@ int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
>  int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
>                         int size, int ps_array_completeness)
>  {
> -    int ret = 0;
> -    uint8_t *buf, *end, *start = NULL;
>      HEVCDecoderConfigurationRecord hvcc;
> -
> -    hvcc_init(&hvcc);
> +    uint8_t *buf, *end, *start;
> +    int ret;
>  
>      if (size < 6) {
>          /* We can't write a valid hvcC from the provided data */
> -        ret = AVERROR_INVALIDDATA;
> -        goto end;
> +        return AVERROR_INVALIDDATA;
>      } else if (*data == 1) {
>          /* Data is already hvcC-formatted */
>          avio_write(pb, data, size);
> -        goto end;
> +        return 0;
>      } else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {
>          /* Not a valid Annex B start code prefix */
> -        ret = AVERROR_INVALIDDATA;
> -        goto end;
> +        return AVERROR_INVALIDDATA;
>      }
>  
>      ret = ff_avc_parse_nal_units_buf(data, &start, &size);
>      if (ret < 0)
> -        goto end;
> +        return ret;
> +
> +    hvcc_init(&hvcc);
>  
>      buf = start;
>      end = start + size;
> 
Ping. Will apply tomorrow unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index a4e53bc4ab..616e9ed49a 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -1070,29 +1070,27 @@  int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
 int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
                        int size, int ps_array_completeness)
 {
-    int ret = 0;
-    uint8_t *buf, *end, *start = NULL;
     HEVCDecoderConfigurationRecord hvcc;
-
-    hvcc_init(&hvcc);
+    uint8_t *buf, *end, *start;
+    int ret;
 
     if (size < 6) {
         /* We can't write a valid hvcC from the provided data */
-        ret = AVERROR_INVALIDDATA;
-        goto end;
+        return AVERROR_INVALIDDATA;
     } else if (*data == 1) {
         /* Data is already hvcC-formatted */
         avio_write(pb, data, size);
-        goto end;
+        return 0;
     } else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {
         /* Not a valid Annex B start code prefix */
-        ret = AVERROR_INVALIDDATA;
-        goto end;
+        return AVERROR_INVALIDDATA;
     }
 
     ret = ff_avc_parse_nal_units_buf(data, &start, &size);
     if (ret < 0)
-        goto end;
+        return ret;
+
+    hvcc_init(&hvcc);
 
     buf = start;
     end = start + size;