[vlc-commits] codec: videotoolbox: align output buffers
Thomas Guillem
git at videolan.org
Tue Sep 19 10:21:11 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Sep 19 10:11:49 2017 +0200| [ae61106f160806ed2cf2de6c374d86b3efd606be] | committer: Thomas Guillem
codec: videotoolbox: align output buffers
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ae61106f160806ed2cf2de6c374d86b3efd606be
---
modules/codec/videotoolbox.m | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index b665e15e19..1662d8e39c 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -48,6 +48,8 @@
#import <sys/sysctl.h>
#import <mach/machine.h>
+#define ALIGN_16( x ) ( ( ( x ) + 15 ) / 16 * 16 )
+
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
@@ -741,8 +743,8 @@ static int StartVideoToolbox(decoder_t *p_dec)
OSStatus status = CMVideoFormatDescriptionCreate(
kCFAllocatorDefault,
p_sys->codec,
- p_dec->fmt_out.video.i_width,
- p_dec->fmt_out.video.i_height,
+ p_dec->fmt_out.video.i_visible_width,
+ p_dec->fmt_out.video.i_visible_height,
decoderConfiguration,
&p_sys->videoFormatDescription);
if (status)
@@ -764,9 +766,9 @@ static int StartVideoToolbox(decoder_t *p_dec)
#endif
cfdict_set_int32(destinationPixelBufferAttributes,
- kCVPixelBufferWidthKey, p_dec->fmt_out.video.i_width);
+ kCVPixelBufferWidthKey, p_dec->fmt_out.video.i_visible_width);
cfdict_set_int32(destinationPixelBufferAttributes,
- kCVPixelBufferHeightKey, p_dec->fmt_out.video.i_height);
+ kCVPixelBufferHeightKey, p_dec->fmt_out.video.i_visible_height);
if (p_sys->i_forced_cvpx_format != 0)
{
@@ -777,6 +779,9 @@ static int StartVideoToolbox(decoder_t *p_dec)
p_sys->i_forced_cvpx_format);
}
+ cfdict_set_int32(destinationPixelBufferAttributes,
+ kCVPixelBufferBytesPerRowAlignmentKey, 16);
+
/* setup decoder callback record */
VTDecompressionOutputCallbackRecord decoderCallbackRecord;
decoderCallbackRecord.decompressionOutputCallback = DecoderCallback;
@@ -980,11 +985,8 @@ static int OpenDecoder(vlc_object_t *p_this)
p_dec->fmt_out.video.i_visible_width = p_dec->fmt_out.video.i_width;
p_dec->fmt_out.video.i_visible_height = p_dec->fmt_out.video.i_height;
}
- else
- {
- p_dec->fmt_out.video.i_width = p_dec->fmt_out.video.i_visible_width;
- p_dec->fmt_out.video.i_height = p_dec->fmt_out.video.i_visible_height;
- }
+ p_dec->fmt_out.video.i_width = ALIGN_16( p_dec->fmt_out.video.i_visible_width );
+ p_dec->fmt_out.video.i_height = ALIGN_16( p_dec->fmt_out.video.i_visible_height );
p_dec->fmt_out.i_codec = 0;
@@ -1179,10 +1181,10 @@ static int SetH264DecoderInfo(decoder_t *p_dec, CFMutableDictionaryRef extradata
p_dec->fmt_out.video.b_color_range_full = full_range;
}
- p_dec->fmt_out.video.i_visible_width =
- p_dec->fmt_out.video.i_width = i_video_width;
- p_dec->fmt_out.video.i_visible_height =
- p_dec->fmt_out.video.i_height = i_video_height;
+ p_dec->fmt_out.video.i_visible_width = i_video_width;
+ p_dec->fmt_out.video.i_width = ALIGN_16( i_video_width );
+ p_dec->fmt_out.video.i_visible_height = i_video_height;
+ p_dec->fmt_out.video.i_height = ALIGN_16( i_video_height );
p_dec->fmt_out.video.i_sar_num = i_sar_num;
p_dec->fmt_out.video.i_sar_den = i_sar_den;
More information about the vlc-commits
mailing list