[FFmpeg-devel] [PATCH 2/2] avcodec/vda_h264_dec: use multichar literal portably

Ganesh Ajjanagadde gajjanagadde at gmail.com
Sat Sep 19 00:16:36 CEST 2015


Multichar literals are implementation defined, and thus trigger -Wmultichar:
http://fate.ffmpeg.org/log.cgi?time=20150918202532&log=compile&slot=x86_64-darwin-gcc-5.
http://www.zipcon.net/~swhite/docs/computers/languages/c_multi-char_const.html
gives a good summary of how to deal with them; in particular this patch
results in behavior identical to that generated by GCC (which I assume is correct this case).

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 libavcodec/vda_h264_dec.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vda_h264_dec.c b/libavcodec/vda_h264_dec.c
index a092693..c3899d8 100644
--- a/libavcodec/vda_h264_dec.c
+++ b/libavcodec/vda_h264_dec.c
@@ -186,22 +186,23 @@ static av_cold int vdadec_init(AVCodecContext *avctx)
     memset(vda_ctx, 0, sizeof(struct vda_context));
     vda_ctx->width = avctx->width;
     vda_ctx->height = avctx->height;
-    vda_ctx->format = 'avc1';
+#define LE_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
+    vda_ctx->format = LE_CHR( 'a', 'v', 'c', '1');
     vda_ctx->use_sync_decoding = 1;
     vda_ctx->use_ref_buffer = 1;
     ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
     switch (ctx->pix_fmt) {
     case AV_PIX_FMT_UYVY422:
-        vda_ctx->cv_pix_fmt_type = '2vuy';
+        vda_ctx->cv_pix_fmt_type = LE_CHR( '2', 'v', 'u', 'y');
         break;
     case AV_PIX_FMT_YUYV422:
-        vda_ctx->cv_pix_fmt_type = 'yuvs';
+        vda_ctx->cv_pix_fmt_type = LE_CHR( 'y', 'u', 'v', 's');
         break;
     case AV_PIX_FMT_NV12:
-        vda_ctx->cv_pix_fmt_type = '420v';
+        vda_ctx->cv_pix_fmt_type = LE_CHR( '4', '2', '0', 'v');
         break;
     case AV_PIX_FMT_YUV420P:
-        vda_ctx->cv_pix_fmt_type = 'y420';
+        vda_ctx->cv_pix_fmt_type = LE_CHR( 'y', '4', '2', '0');
         break;
     default:
         av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt);
-- 
2.5.2



More information about the ffmpeg-devel mailing list