Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From 427732a379893491eac27aeadff0e0b3e252d158 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jean-Baptiste Kempf <jb@videolan.org> |
| 3 | Date: Mon, 31 Aug 2015 08:19:00 +0200 |
| 4 | Subject: [PATCH] Avcodec/swscale: use AV_PIX_FMT consistently |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | (cherry picked from commit faa7bd357b1f9e07a6ffbc451a188773fad7a275) |
| 10 | Signed-off-by: Rafaël Carré <funman@videolan.org> |
| 11 | |
| 12 | Conflicts: |
| 13 | modules/codec/avcodec/chroma.c |
| 14 | modules/codec/avcodec/video.c |
| 15 | --- |
| 16 | modules/codec/avcodec/chroma.c | 104 ++++++++++++++++++++--------------------- |
| 17 | modules/codec/avcodec/video.c | 10 ++-- |
| 18 | modules/video_chroma/swscale.c | 28 +++++------ |
| 19 | 3 files changed, 71 insertions(+), 71 deletions(-) |
| 20 | |
| 21 | diff --git a/modules/codec/avcodec/chroma.c b/modules/codec/avcodec/chroma.c |
| 22 | index 393364b..c31f93d 100644 |
| 23 | --- a/modules/codec/avcodec/chroma.c |
| 24 | +++ b/modules/codec/avcodec/chroma.c |
| 25 | @@ -62,77 +62,77 @@ static const struct |
| 26 | } chroma_table[] = |
| 27 | { |
| 28 | /* Planar YUV formats */ |
| 29 | - {VLC_CODEC_I444, PIX_FMT_YUV444P, 0, 0, 0 }, |
| 30 | - {VLC_CODEC_J444, PIX_FMT_YUVJ444P, 0, 0, 0 }, |
| 31 | - |
| 32 | - {VLC_CODEC_I440, PIX_FMT_YUV440P, 0, 0, 0 }, |
| 33 | - {VLC_CODEC_J440, PIX_FMT_YUVJ440P, 0, 0, 0 }, |
| 34 | - |
| 35 | - {VLC_CODEC_I422, PIX_FMT_YUV422P, 0, 0, 0 }, |
| 36 | - {VLC_CODEC_J422, PIX_FMT_YUVJ422P, 0, 0, 0 }, |
| 37 | - |
| 38 | - {VLC_CODEC_I420, PIX_FMT_YUV420P, 0, 0, 0 }, |
| 39 | - {VLC_CODEC_YV12, PIX_FMT_YUV420P, 0, 0, 0 }, |
| 40 | - {VLC_FOURCC('I','Y','U','V'), PIX_FMT_YUV420P, 0, 0, 0 }, |
| 41 | - {VLC_CODEC_J420, PIX_FMT_YUVJ420P, 0, 0, 0 }, |
| 42 | - {VLC_CODEC_I411, PIX_FMT_YUV411P, 0, 0, 0 }, |
| 43 | - {VLC_CODEC_I410, PIX_FMT_YUV410P, 0, 0, 0 }, |
| 44 | - {VLC_FOURCC('Y','V','U','9'), PIX_FMT_YUV410P, 0, 0, 0 }, |
| 45 | - |
| 46 | - {VLC_FOURCC('N','V','1','2'), PIX_FMT_NV12, 0, 0, 0 }, |
| 47 | - {VLC_FOURCC('N','V','2','1'), PIX_FMT_NV21, 0, 0, 0 }, |
| 48 | - |
| 49 | - {VLC_CODEC_I420_9L, PIX_FMT_YUV420P9LE, 0, 0, 0 }, |
| 50 | - {VLC_CODEC_I420_9B, PIX_FMT_YUV420P9BE, 0, 0, 0 }, |
| 51 | - {VLC_CODEC_I420_10L, PIX_FMT_YUV420P10LE, 0, 0, 0 }, |
| 52 | - {VLC_CODEC_I420_10B, PIX_FMT_YUV420P10BE, 0, 0, 0 }, |
| 53 | + {VLC_CODEC_I444, AV_PIX_FMT_YUV444P, 0, 0, 0 }, |
| 54 | + {VLC_CODEC_J444, AV_PIX_FMT_YUVJ444P, 0, 0, 0 }, |
| 55 | + |
| 56 | + {VLC_CODEC_I440, AV_PIX_FMT_YUV440P, 0, 0, 0 }, |
| 57 | + {VLC_CODEC_J440, AV_PIX_FMT_YUVJ440P, 0, 0, 0 }, |
| 58 | + |
| 59 | + {VLC_CODEC_I422, AV_PIX_FMT_YUV422P, 0, 0, 0 }, |
| 60 | + {VLC_CODEC_J422, AV_PIX_FMT_YUVJ422P, 0, 0, 0 }, |
| 61 | + |
| 62 | + {VLC_CODEC_I420, AV_PIX_FMT_YUV420P, 0, 0, 0 }, |
| 63 | + {VLC_CODEC_YV12, AV_PIX_FMT_YUV420P, 0, 0, 0 }, |
| 64 | + {VLC_FOURCC('I','Y','U','V'), AV_PIX_FMT_YUV420P, 0, 0, 0 }, |
| 65 | + {VLC_CODEC_J420, AV_PIX_FMT_YUVJ420P, 0, 0, 0 }, |
| 66 | + {VLC_CODEC_I411, AV_PIX_FMT_YUV411P, 0, 0, 0 }, |
| 67 | + {VLC_CODEC_I410, AV_PIX_FMT_YUV410P, 0, 0, 0 }, |
| 68 | + {VLC_FOURCC('Y','V','U','9'), AV_PIX_FMT_YUV410P, 0, 0, 0 }, |
| 69 | + |
| 70 | + {VLC_FOURCC('N','V','1','2'), AV_PIX_FMT_NV12, 0, 0, 0 }, |
| 71 | + {VLC_FOURCC('N','V','2','1'), AV_PIX_FMT_NV21, 0, 0, 0 }, |
| 72 | + |
| 73 | + {VLC_CODEC_I420_9L, AV_PIX_FMT_YUV420P9LE, 0, 0, 0 }, |
| 74 | + {VLC_CODEC_I420_9B, AV_PIX_FMT_YUV420P9BE, 0, 0, 0 }, |
| 75 | + {VLC_CODEC_I420_10L, AV_PIX_FMT_YUV420P10LE, 0, 0, 0 }, |
| 76 | + {VLC_CODEC_I420_10B, AV_PIX_FMT_YUV420P10BE, 0, 0, 0 }, |
| 77 | #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,13,0) |
| 78 | - {VLC_CODEC_I422_9L, PIX_FMT_YUV422P9LE, 0, 0, 0 }, |
| 79 | - {VLC_CODEC_I422_9B, PIX_FMT_YUV422P9BE, 0, 0, 0 }, |
| 80 | + {VLC_CODEC_I422_9L, AV_PIX_FMT_YUV422P9LE, 0, 0, 0 }, |
| 81 | + {VLC_CODEC_I422_9B, AV_PIX_FMT_YUV422P9BE, 0, 0, 0 }, |
| 82 | #endif |
| 83 | - {VLC_CODEC_I422_10L, PIX_FMT_YUV422P10LE, 0, 0, 0 }, |
| 84 | - {VLC_CODEC_I422_10B, PIX_FMT_YUV422P10BE, 0, 0, 0 }, |
| 85 | + {VLC_CODEC_I422_10L, AV_PIX_FMT_YUV422P10LE, 0, 0, 0 }, |
| 86 | + {VLC_CODEC_I422_10B, AV_PIX_FMT_YUV422P10BE, 0, 0, 0 }, |
| 87 | |
| 88 | - {VLC_CODEC_YUV420A, PIX_FMT_YUVA420P, 0, 0, 0 }, |
| 89 | + {VLC_CODEC_YUV420A, AV_PIX_FMT_YUVA420P, 0, 0, 0 }, |
| 90 | #if LIBAVUTIL_VERSION_CHECK( 51, 45, 0, 74, 100 ) |
| 91 | {VLC_CODEC_YUV422A, AV_PIX_FMT_YUVA422P, 0, 0, 0 }, |
| 92 | #endif |
| 93 | |
| 94 | - {VLC_CODEC_I444_9L, PIX_FMT_YUV444P9LE, 0, 0, 0 }, |
| 95 | - {VLC_CODEC_I444_9B, PIX_FMT_YUV444P9BE, 0, 0, 0 }, |
| 96 | - {VLC_CODEC_I444_10L, PIX_FMT_YUV444P10LE, 0, 0, 0 }, |
| 97 | - {VLC_CODEC_I444_10B, PIX_FMT_YUV444P10BE, 0, 0, 0 }, |
| 98 | - {VLC_CODEC_I444_16L, PIX_FMT_YUV444P16LE, 0, 0, 0 }, |
| 99 | - {VLC_CODEC_I444_16B, PIX_FMT_YUV444P16BE, 0, 0, 0 }, |
| 100 | + {VLC_CODEC_I444_9L, AV_PIX_FMT_YUV444P9LE, 0, 0, 0 }, |
| 101 | + {VLC_CODEC_I444_9B, AV_PIX_FMT_YUV444P9BE, 0, 0, 0 }, |
| 102 | + {VLC_CODEC_I444_10L, AV_PIX_FMT_YUV444P10LE, 0, 0, 0 }, |
| 103 | + {VLC_CODEC_I444_10B, AV_PIX_FMT_YUV444P10BE, 0, 0, 0 }, |
| 104 | + {VLC_CODEC_I444_16L, AV_PIX_FMT_YUV444P16LE, 0, 0, 0 }, |
| 105 | + {VLC_CODEC_I444_16B, AV_PIX_FMT_YUV444P16BE, 0, 0, 0 }, |
| 106 | |
| 107 | /* Packed YUV formats */ |
| 108 | - {VLC_CODEC_YUYV, PIX_FMT_YUYV422, 0, 0, 0 }, |
| 109 | - {VLC_FOURCC('Y','U','Y','V'), PIX_FMT_YUYV422, 0, 0, 0 }, |
| 110 | - {VLC_CODEC_UYVY, PIX_FMT_UYVY422, 0, 0, 0 }, |
| 111 | - {VLC_FOURCC('Y','4','1','1'), PIX_FMT_UYYVYY411, 0, 0, 0 }, |
| 112 | + {VLC_CODEC_YUYV, AV_PIX_FMT_YUYV422, 0, 0, 0 }, |
| 113 | + {VLC_FOURCC('Y','U','Y','V'), AV_PIX_FMT_YUYV422, 0, 0, 0 }, |
| 114 | + {VLC_CODEC_UYVY, AV_PIX_FMT_UYVY422, 0, 0, 0 }, |
| 115 | + {VLC_FOURCC('Y','4','1','1'), AV_PIX_FMT_UYYVYY411, 0, 0, 0 }, |
| 116 | |
| 117 | /* Packed RGB formats */ |
| 118 | - VLC_RGB( VLC_FOURCC('R','G','B','4'), PIX_FMT_RGB4, PIX_FMT_BGR4, 0x10, 0x06, 0x01 ) |
| 119 | - VLC_RGB( VLC_FOURCC('R','G','B','8'), PIX_FMT_RGB8, PIX_FMT_BGR8, 0xC0, 0x38, 0x07 ) |
| 120 | + VLC_RGB( VLC_FOURCC('R','G','B','4'), AV_PIX_FMT_RGB4, AV_PIX_FMT_BGR4, 0x10, 0x06, 0x01 ) |
| 121 | + VLC_RGB( VLC_FOURCC('R','G','B','8'), AV_PIX_FMT_RGB8, AV_PIX_FMT_BGR8, 0xC0, 0x38, 0x07 ) |
| 122 | |
| 123 | - VLC_RGB( VLC_CODEC_RGB15, PIX_FMT_RGB555, PIX_FMT_BGR555, 0x7c00, 0x03e0, 0x001f ) |
| 124 | - VLC_RGB( VLC_CODEC_RGB16, PIX_FMT_RGB565, PIX_FMT_BGR565, 0xf800, 0x07e0, 0x001f ) |
| 125 | - VLC_RGB( VLC_CODEC_RGB24, PIX_FMT_BGR24, PIX_FMT_RGB24, 0xff0000, 0x00ff00, 0x0000ff ) |
| 126 | + VLC_RGB( VLC_CODEC_RGB15, AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555, 0x7c00, 0x03e0, 0x001f ) |
| 127 | + VLC_RGB( VLC_CODEC_RGB16, AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565, 0xf800, 0x07e0, 0x001f ) |
| 128 | + VLC_RGB( VLC_CODEC_RGB24, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, 0xff0000, 0x00ff00, 0x0000ff ) |
| 129 | |
| 130 | - VLC_RGB( VLC_CODEC_RGB32, PIX_FMT_RGB32, PIX_FMT_BGR32, 0x00ff0000, 0x0000ff00, 0x000000ff ) |
| 131 | - VLC_RGB( VLC_CODEC_RGB32, PIX_FMT_RGB32_1, PIX_FMT_BGR32_1, 0xff000000, 0x00ff0000, 0x0000ff00 ) |
| 132 | + VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_RGB32, AV_PIX_FMT_BGR32, 0x00ff0000, 0x0000ff00, 0x000000ff ) |
| 133 | + VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_RGB32_1, AV_PIX_FMT_BGR32_1, 0xff000000, 0x00ff0000, 0x0000ff00 ) |
| 134 | |
| 135 | #ifdef AV_PIX_FMT_0BGR32 |
| 136 | VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_0BGR32, AV_PIX_FMT_0RGB32, 0x000000ff, 0x0000ff00, 0x00ff0000 ) |
| 137 | #endif |
| 138 | |
| 139 | - {VLC_CODEC_RGBA, PIX_FMT_RGBA, 0, 0, 0 }, |
| 140 | - {VLC_CODEC_ARGB, PIX_FMT_ARGB, 0, 0, 0 }, |
| 141 | - {VLC_CODEC_BGRA, PIX_FMT_BGRA, 0, 0, 0 }, |
| 142 | - {VLC_CODEC_GREY, PIX_FMT_GRAY8, 0, 0, 0}, |
| 143 | + {VLC_CODEC_RGBA, AV_PIX_FMT_RGBA, 0, 0, 0 }, |
| 144 | + {VLC_CODEC_ARGB, AV_PIX_FMT_ARGB, 0, 0, 0 }, |
| 145 | + {VLC_CODEC_BGRA, AV_PIX_FMT_BGRA, 0, 0, 0 }, |
| 146 | + {VLC_CODEC_GREY, AV_PIX_FMT_GRAY8, 0, 0, 0}, |
| 147 | |
| 148 | /* Paletized RGB */ |
| 149 | - {VLC_CODEC_RGBP, PIX_FMT_PAL8, 0, 0, 0}, |
| 150 | + {VLC_CODEC_RGBP, AV_PIX_FMT_PAL8, 0, 0, 0}, |
| 151 | |
| 152 | #if LIBAVUTIL_VERSION_CHECK(51, 42, 0, 74,100) |
| 153 | {VLC_CODEC_GBR_PLANAR, AV_PIX_FMT_GBRP, 0, 0, 0 }, |
| 154 | @@ -201,5 +201,5 @@ int FindFfmpegChroma( vlc_fourcc_t fourcc ) |
| 155 | for( int i = 0; chroma_table[i].i_chroma != 0; i++ ) |
| 156 | if( chroma_table[i].i_chroma == fourcc ) |
| 157 | return chroma_table[i].i_chroma_id; |
| 158 | - return PIX_FMT_NONE; |
| 159 | + return AV_PIX_FMT_NONE; |
| 160 | } |
| 161 | diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c |
| 162 | index c115db9..ae600e8 100644 |
| 163 | --- a/modules/codec/avcodec/video.c |
| 164 | +++ b/modules/codec/avcodec/video.c |
| 165 | @@ -1004,7 +1004,7 @@ static picture_t *lavc_dr_GetFrame(struct AVCodecContext *ctx, |
| 166 | if (GetVlcChroma(&dec->fmt_out.video, ctx->pix_fmt) != VLC_SUCCESS) |
| 167 | return NULL; |
| 168 | dec->fmt_out.i_codec = dec->fmt_out.video.i_chroma; |
| 169 | - if (ctx->pix_fmt == PIX_FMT_PAL8) |
| 170 | + if (ctx->pix_fmt == AV_PIX_FMT_PAL8) |
| 171 | return NULL; |
| 172 | |
| 173 | int width = frame->width; |
| 174 | @@ -1180,7 +1180,7 @@ static picture_t *ffmpeg_dr_GetFrameBuf(struct AVCodecContext *p_context) |
| 175 | if (GetVlcChroma(&p_dec->fmt_out.video, p_context->pix_fmt) != VLC_SUCCESS) |
| 176 | goto no_dr; |
| 177 | |
| 178 | - if (p_context->pix_fmt == PIX_FMT_PAL8) |
| 179 | + if (p_context->pix_fmt == AV_PIX_FMT_PAL8) |
| 180 | goto no_dr; |
| 181 | |
| 182 | p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma; |
| 183 | @@ -1215,7 +1215,7 @@ static picture_t *ffmpeg_dr_GetFrameBuf(struct AVCodecContext *p_context) |
| 184 | goto no_dr; |
| 185 | } |
| 186 | |
| 187 | - if( p_context->pix_fmt == PIX_FMT_YUV422P ) |
| 188 | + if( p_context->pix_fmt == AV_PIX_FMT_YUV422P ) |
| 189 | { |
| 190 | if( 2 * p_pic->p[1].i_pitch != p_pic->p[0].i_pitch || |
| 191 | 2 * p_pic->p[2].i_pitch != p_pic->p[0].i_pitch ) |
| 192 | @@ -1325,7 +1325,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context, |
| 193 | |
| 194 | /* Enumerate available formats */ |
| 195 | bool can_hwaccel = false; |
| 196 | - for( size_t i = 0; pi_fmt[i] != PIX_FMT_NONE; i++ ) |
| 197 | + for( size_t i = 0; pi_fmt[i] != AV_PIX_FMT_NONE; i++ ) |
| 198 | { |
| 199 | const AVPixFmtDescriptor *dsc = av_pix_fmt_desc_get(pi_fmt[i]); |
| 200 | if (dsc == NULL) |
| 201 | @@ -1352,7 +1352,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context, |
| 202 | if( p_va == NULL ) |
| 203 | goto end; |
| 204 | |
| 205 | - for( size_t i = 0; pi_fmt[i] != PIX_FMT_NONE; i++ ) |
| 206 | + for( size_t i = 0; pi_fmt[i] != AV_PIX_FMT_NONE; i++ ) |
| 207 | { |
| 208 | if( p_va->pix_fmt != pi_fmt[i] ) |
| 209 | continue; |
| 210 | diff --git a/modules/video_chroma/swscale.c b/modules/video_chroma/swscale.c |
| 211 | index 569e0f5..4e0ecf1 100644 |
| 212 | --- a/modules/video_chroma/swscale.c |
| 213 | +++ b/modules/video_chroma/swscale.c |
| 214 | @@ -257,35 +257,35 @@ static void FixParameters( int *pi_fmt, bool *pb_has_a, bool *pb_swap_uv, vlc_fo |
| 215 | switch( fmt ) |
| 216 | { |
| 217 | case VLC_CODEC_YUV422A: |
| 218 | - *pi_fmt = PIX_FMT_YUV422P; |
| 219 | + *pi_fmt = AV_PIX_FMT_YUV422P; |
| 220 | *pb_has_a = true; |
| 221 | break; |
| 222 | case VLC_CODEC_YUV420A: |
| 223 | - *pi_fmt = PIX_FMT_YUV420P; |
| 224 | + *pi_fmt = AV_PIX_FMT_YUV420P; |
| 225 | *pb_has_a = true; |
| 226 | break; |
| 227 | case VLC_CODEC_YUVA: |
| 228 | - *pi_fmt = PIX_FMT_YUV444P; |
| 229 | + *pi_fmt = AV_PIX_FMT_YUV444P; |
| 230 | *pb_has_a = true; |
| 231 | break; |
| 232 | case VLC_CODEC_RGBA: |
| 233 | - *pi_fmt = PIX_FMT_BGR32; |
| 234 | + *pi_fmt = AV_PIX_FMT_BGR32; |
| 235 | *pb_has_a = true; |
| 236 | break; |
| 237 | case VLC_CODEC_ARGB: |
| 238 | - *pi_fmt = PIX_FMT_BGR32_1; |
| 239 | + *pi_fmt = AV_PIX_FMT_BGR32_1; |
| 240 | *pb_has_a = true; |
| 241 | break; |
| 242 | case VLC_CODEC_BGRA: |
| 243 | - *pi_fmt = PIX_FMT_RGB32; |
| 244 | + *pi_fmt = AV_PIX_FMT_RGB32; |
| 245 | *pb_has_a = true; |
| 246 | break; |
| 247 | case VLC_CODEC_YV12: |
| 248 | - *pi_fmt = PIX_FMT_YUV420P; |
| 249 | + *pi_fmt = AV_PIX_FMT_YUV420P; |
| 250 | *pb_swap_uv = true; |
| 251 | break; |
| 252 | case VLC_CODEC_YV9: |
| 253 | - *pi_fmt = PIX_FMT_YUV410P; |
| 254 | + *pi_fmt = AV_PIX_FMT_YUV410P; |
| 255 | *pb_swap_uv = true; |
| 256 | break; |
| 257 | default: |
| 258 | @@ -314,7 +314,7 @@ static int GetParameters( ScalerConfiguration *p_cfg, |
| 259 | { |
| 260 | if( p_fmti->i_chroma == VLC_CODEC_YUVP && ALLOW_YUVP ) |
| 261 | { |
| 262 | - i_fmti = i_fmto = PIX_FMT_GRAY8; |
| 263 | + i_fmti = i_fmto = AV_PIX_FMT_GRAY8; |
| 264 | i_sws_flags = SWS_POINT; |
| 265 | } |
| 266 | } |
| 267 | @@ -327,9 +327,9 @@ static int GetParameters( ScalerConfiguration *p_cfg, |
| 268 | * Without SWS_ACCURATE_RND the quality is really bad for some conversions */ |
| 269 | switch( i_fmto ) |
| 270 | { |
| 271 | - case PIX_FMT_ARGB: |
| 272 | - case PIX_FMT_RGBA: |
| 273 | - case PIX_FMT_ABGR: |
| 274 | + case AV_PIX_FMT_ARGB: |
| 275 | + case AV_PIX_FMT_RGBA: |
| 276 | + case AV_PIX_FMT_ABGR: |
| 277 | i_sws_flags |= SWS_ACCURATE_RND; |
| 278 | break; |
| 279 | } |
| 280 | @@ -403,8 +403,8 @@ static int Init( filter_t *p_filter ) |
| 281 | const unsigned i_fmto_visible_width = p_fmto->i_visible_width * p_sys->i_extend_factor; |
| 282 | for( int n = 0; n < (cfg.b_has_a ? 2 : 1); n++ ) |
| 283 | { |
| 284 | - const int i_fmti = n == 0 ? cfg.i_fmti : PIX_FMT_GRAY8; |
| 285 | - const int i_fmto = n == 0 ? cfg.i_fmto : PIX_FMT_GRAY8; |
| 286 | + const int i_fmti = n == 0 ? cfg.i_fmti : AV_PIX_FMT_GRAY8; |
| 287 | + const int i_fmto = n == 0 ? cfg.i_fmto : AV_PIX_FMT_GRAY8; |
| 288 | struct SwsContext *ctx; |
| 289 | |
| 290 | ctx = sws_getContext( i_fmti_visible_width, p_fmti->i_visible_height, i_fmti, |
| 291 | -- |
| 292 | 2.5.0 |
| 293 | |