Re: [libav-devel] [PATCH] hwframe: Support cropping in the default allocator

2017-06-26 Thread wm4
On Sun, 25 Jun 2017 14:50:32 -0400
Vittorio Giovara  wrote:

> On Sat, Jun 24, 2017 at 12:18 PM, wm4  wrote:
> > On Sat, 24 Jun 2017 15:51:20 +0200
> > Luca Barbato  wrote:
> >  
> >> From: Anton Khirnov 
> >>
> >> ---
> >>
> >> Better subject welcome. It is currently folded in wm4 mix fixes set.  
> 
> It would be nice to have a short description about why this is
> correct/needed in the commit log.

Suggestion:

hwframe: allow hwaccel frame allocators to align surface sizes

Hardware accelerated decoding generally uses AVHWFramesContext for pool
allocation of hardware surfaces. These are setup to allocate surfaces
aligned to hardware and hwaccel API requirements. Due to the
architecture, av_hwframe_get_buffer() will return AVFrames with
the dimensions set to the aligned sizes.

This causes some decoders (like hevc) return these aligned size as
final frame size, instead of cropping them to the video's actual
dimensions. To make sure this doesn't happen, crop the frame to the
size the decoder expects when ff_get_buffer() is called.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] hwframe: Support cropping in the default allocator

2017-06-25 Thread Vittorio Giovara
On Sat, Jun 24, 2017 at 12:18 PM, wm4  wrote:
> On Sat, 24 Jun 2017 15:51:20 +0200
> Luca Barbato  wrote:
>
>> From: Anton Khirnov 
>>
>> ---
>>
>> Better subject welcome. It is currently folded in wm4 mix fixes set.

It would be nice to have a short description about why this is
correct/needed in the commit log.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] hwframe: Support cropping in the default allocator

2017-06-24 Thread wm4
On Sat, 24 Jun 2017 15:51:20 +0200
Luca Barbato  wrote:

> From: Anton Khirnov 
> 
> ---
> 
> Better subject welcome. It is currently folded in wm4 mix fixes set.
> 
>  libavcodec/decode.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index ae2c715677..175a6fae4c 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1006,8 +1006,12 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, 
> AVFrame *frame, int flags
>  {
>  int ret;
> 
> -if (avctx->hw_frames_ctx)
> -return av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
> +if (avctx->hw_frames_ctx) {
> +ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
> +frame->width  = avctx->coded_width;
> +frame->height = avctx->coded_height;
> +return ret;
> +}
> 
>  if ((ret = update_frame_pool(avctx, frame)) < 0)
>  return ret;

Looks good to me - certainly doesn't make things worse.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH] hwframe: Support cropping in the default allocator

2017-06-24 Thread Luca Barbato
From: Anton Khirnov 

---

Better subject welcome. It is currently folded in wm4 mix fixes set.

 libavcodec/decode.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index ae2c715677..175a6fae4c 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1006,8 +1006,12 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, 
AVFrame *frame, int flags
 {
 int ret;

-if (avctx->hw_frames_ctx)
-return av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
+if (avctx->hw_frames_ctx) {
+ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
+frame->width  = avctx->coded_width;
+frame->height = avctx->coded_height;
+return ret;
+}

 if ((ret = update_frame_pool(avctx, frame)) < 0)
 return ret;
--
2.12.2

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