diff mbox

[FFmpeg-devel,3/3] cbs_h2645: Allocate all internal buffers with padding

Message ID 20181016210128.7652-3-sw@jkqxz.net
State Accepted
Commit da6db843b80e6140dbf28f05195b6a17018fd68c
Headers show

Commit Message

Mark Thompson Oct. 16, 2018, 9:01 p.m. UTC
Any of these buffers (for both H.264 and H.265) might reasonably be
parsed using the bitstream reader, so include padding on all of them.
---
This seems simpler than adding it to specific cases as problems are found.


 libavcodec/cbs_h2645.c                | 3 ++-
 libavcodec/cbs_h264_syntax_template.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Aman Karmani Oct. 17, 2018, 12:40 a.m. UTC | #1
On Tue, Oct 16, 2018 at 2:08 PM Mark Thompson <sw@jkqxz.net> wrote:

> Any of these buffers (for both H.264 and H.265) might reasonably be
> parsed using the bitstream reader, so include padding on all of them.
> ---
> This seems simpler than adding it to specific cases as problems are found.
>
>
Entire patchset looks great to me. Thanks for cleaning up my mess.

Aman


>
>  libavcodec/cbs_h2645.c                | 3 ++-
>  libavcodec/cbs_h264_syntax_template.c | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index a1b92c87ce..e55bd00183 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -319,7 +319,8 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext
> *gbc)
>  #define byte_alignment(rw) (get_bits_count(rw) % 8)
>
>  #define allocate(name, size) do { \
> -        name ## _ref = av_buffer_allocz(size); \
> +        name ## _ref = av_buffer_allocz(size + \
> +                                        AV_INPUT_BUFFER_PADDING_SIZE); \
>          if (!name ## _ref) \
>              return AVERROR(ENOMEM); \
>          name = name ## _ref->data; \
> diff --git a/libavcodec/cbs_h264_syntax_template.c
> b/libavcodec/cbs_h264_syntax_template.c
> index 7d0ce5918a..9e29132fec 100644
> --- a/libavcodec/cbs_h264_syntax_template.c
> +++ b/libavcodec/cbs_h264_syntax_template.c
> @@ -718,7 +718,7 @@ static int
> FUNC(sei_user_data_registered)(CodedBitstreamContext *ctx, RWContext
>      *payload_size = i + current->data_length;
>  #endif
>
> -    allocate(current->data, current->data_length +
> AV_INPUT_BUFFER_PADDING_SIZE);
> +    allocate(current->data, current->data_length);
>      for (j = 0; j < current->data_length; j++)
>          xu(8, itu_t_t35_payload_byte[i], current->data[j], 0x00, 0xff, 1,
> i + j);
>
> --
> 2.19.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Mark Thompson Oct. 22, 2018, 10:21 p.m. UTC | #2
On 17/10/18 01:40, Aman Gupta wrote:
> On Tue, Oct 16, 2018 at 2:08 PM Mark Thompson <sw@jkqxz.net> wrote:
> 
>> Any of these buffers (for both H.264 and H.265) might reasonably be
>> parsed using the bitstream reader, so include padding on all of them.
>> ---
>> This seems simpler than adding it to specific cases as problems are found.
>>
>>
> Entire patchset looks great to me.

Applied.

Thank you!

- Mark
diff mbox

Patch

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index a1b92c87ce..e55bd00183 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -319,7 +319,8 @@  static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
 #define byte_alignment(rw) (get_bits_count(rw) % 8)
 
 #define allocate(name, size) do { \
-        name ## _ref = av_buffer_allocz(size); \
+        name ## _ref = av_buffer_allocz(size + \
+                                        AV_INPUT_BUFFER_PADDING_SIZE); \
         if (!name ## _ref) \
             return AVERROR(ENOMEM); \
         name = name ## _ref->data; \
diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c
index 7d0ce5918a..9e29132fec 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -718,7 +718,7 @@  static int FUNC(sei_user_data_registered)(CodedBitstreamContext *ctx, RWContext
     *payload_size = i + current->data_length;
 #endif
 
-    allocate(current->data, current->data_length + AV_INPUT_BUFFER_PADDING_SIZE);
+    allocate(current->data, current->data_length);
     for (j = 0; j < current->data_length; j++)
         xu(8, itu_t_t35_payload_byte[i], current->data[j], 0x00, 0xff, 1, i + j);