diff mbox series

[FFmpeg-devel,v2] avcodec/hevc_refs: don't use the frame's AVBufferRef sizes when initializing planes

Message ID 20220308135500.7268-1-jamrial@gmail.com
State Accepted
Commit 3aeeee1597abd6c12308fbc2f4087d7c943166df
Headers show
Series [FFmpeg-devel,v2] avcodec/hevc_refs: don't use the frame's AVBufferRef sizes when initializing planes | expand

Checks

Context Check Description
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

James Almer March 8, 2022, 1:55 p.m. UTC
Use the actual plane sizes instead.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/hevc_refs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Anton Khirnov March 15, 2022, 8:53 a.m. UTC | #1
Quoting James Almer (2022-03-08 14:55:00)
> Use the actual plane sizes instead.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/hevc_refs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
> index 35b8e5e696..fe18ca2b1d 100644
> --- a/libavcodec/hevc_refs.c
> +++ b/libavcodec/hevc_refs.c
> @@ -401,9 +401,9 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
>  
>      if (!s->avctx->hwaccel) {
>          if (!s->ps.sps->pixel_shift) {
> -            for (i = 0; frame->frame->buf[i]; i++)
> -                memset(frame->frame->buf[i]->data, 1 << (s->ps.sps->bit_depth - 1),
> -                       frame->frame->buf[i]->size);
> +            for (i = 0; frame->frame->data[i]; i++)
> +                memset(frame->frame->data[i], 1 << (s->ps.sps->bit_depth - 1),
> +                       frame->frame->linesize[i] * AV_CEIL_RSHIFT(s->ps.sps->height, s->ps.sps->vshift[i]));

Looks good.
James Almer March 15, 2022, 9:18 p.m. UTC | #2
On 3/15/2022 5:53 AM, Anton Khirnov wrote:
> Quoting James Almer (2022-03-08 14:55:00)
>> Use the actual plane sizes instead.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavcodec/hevc_refs.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
>> index 35b8e5e696..fe18ca2b1d 100644
>> --- a/libavcodec/hevc_refs.c
>> +++ b/libavcodec/hevc_refs.c
>> @@ -401,9 +401,9 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
>>   
>>       if (!s->avctx->hwaccel) {
>>           if (!s->ps.sps->pixel_shift) {
>> -            for (i = 0; frame->frame->buf[i]; i++)
>> -                memset(frame->frame->buf[i]->data, 1 << (s->ps.sps->bit_depth - 1),
>> -                       frame->frame->buf[i]->size);
>> +            for (i = 0; frame->frame->data[i]; i++)
>> +                memset(frame->frame->data[i], 1 << (s->ps.sps->bit_depth - 1),
>> +                       frame->frame->linesize[i] * AV_CEIL_RSHIFT(s->ps.sps->height, s->ps.sps->vshift[i]));
> 
> Looks good.

Applied, thanks.
diff mbox series

Patch

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 35b8e5e696..fe18ca2b1d 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -401,9 +401,9 @@  static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
 
     if (!s->avctx->hwaccel) {
         if (!s->ps.sps->pixel_shift) {
-            for (i = 0; frame->frame->buf[i]; i++)
-                memset(frame->frame->buf[i]->data, 1 << (s->ps.sps->bit_depth - 1),
-                       frame->frame->buf[i]->size);
+            for (i = 0; frame->frame->data[i]; i++)
+                memset(frame->frame->data[i], 1 << (s->ps.sps->bit_depth - 1),
+                       frame->frame->linesize[i] * AV_CEIL_RSHIFT(s->ps.sps->height, s->ps.sps->vshift[i]));
         } else {
             for (i = 0; frame->frame->data[i]; i++)
                 for (y = 0; y < (s->ps.sps->height >> s->ps.sps->vshift[i]); y++) {