summaryrefslogtreecommitdiff
path: root/libavcodec/libutvideo.cpp
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2011-11-06 23:51:47 -0500
committerMichael Niedermayer <michaelni@gmx.at>2011-11-07 15:01:19 +0100
commite3475198779f806115079c9128172543b37243e6 (patch)
tree812c5ebd4836a1730d58ed90d0c465d63cf1f023 /libavcodec/libutvideo.cpp
parent13665c87678bb064d4ab7e954a02a9337351460d (diff)
libutvideo: Don't try and output original_format
The original format field in Ut Video's extradata should not be used to determine the output format. Cases can occur where the original format differs from the actual current format, and thus should not be used as the output format. Instead, rely solely on the FOURCC. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libutvideo.cpp')
-rw-r--r--libavcodec/libutvideo.cpp56
1 files changed, 14 insertions, 42 deletions
diff --git a/libavcodec/libutvideo.cpp b/libavcodec/libutvideo.cpp
index 15e6840afa..f10b6f103e 100644
--- a/libavcodec/libutvideo.cpp
+++ b/libavcodec/libutvideo.cpp
@@ -51,7 +51,7 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx)
{
UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
UtVideoExtra info;
- int defined_fourcc = 0;
+ int format;
if(avctx->extradata_size != 4*4)
{
@@ -65,55 +65,28 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx)
info.stripes = AV_RL32(avctx->extradata + 8);
info.flags = AV_RL32(avctx->extradata + 12);
- /* Try to output the original format */
- switch(UNFCC(info.original_format))
+ /* Pick format based on FOURCC */
+ switch(avctx->codec_tag)
{
- case UTVF_YV12:
+ case MKTAG('U', 'L', 'Y', '0'):
avctx->pix_fmt = PIX_FMT_YUV420P;
+ format = UTVF_YV12;
break;
- case UTVF_YUY2:
- case UTVF_YUYV:
- case UTVF_YUNV:
+ case MKTAG('U', 'L', 'Y', '2'):
avctx->pix_fmt = PIX_FMT_YUYV422;
+ format = UTVF_YUY2;
break;
- case UTVF_UYVY:
- case UTVF_UYNV:
- avctx->pix_fmt = PIX_FMT_UYVY422;
- break;
- case UTVF_RGB24_WIN:
+ case MKTAG('U', 'L', 'R', 'G'):
avctx->pix_fmt = PIX_FMT_BGR24;
+ format = UTVF_RGB24_WIN;
break;
- case UTVF_RGB32_WIN:
+ case MKTAG('U', 'L', 'R', 'A'):
avctx->pix_fmt = PIX_FMT_RGB32;
- break;
- case UTVF_ARGB32_WIN:
- avctx->pix_fmt = PIX_FMT_ARGB;
- break;
- case 0:
- /* Fall back on FOURCC */
- switch(UNFCC(avctx->codec_tag))
- {
- case UTVF_ULY0:
- avctx->pix_fmt = PIX_FMT_YUV420P;
- defined_fourcc = UTVF_YV12;
- break;
- case UTVF_ULY2:
- avctx->pix_fmt = PIX_FMT_YUYV422;
- defined_fourcc = UTVF_YUY2;
- break;
- case UTVF_ULRG:
- avctx->pix_fmt = PIX_FMT_BGR24;
- defined_fourcc = UTVF_RGB24_WIN;
- break;
- case UTVF_ULRA:
- avctx->pix_fmt = PIX_FMT_RGB32;
- defined_fourcc = UTVF_RGB32_WIN;
- break;
- }
+ format = UTVF_RGB32_WIN;
break;
default:
av_log(avctx, AV_LOG_ERROR,
- "Codec ExtraData is Corrupt or Invalid: %X\n", info.original_format);
+ "Not a Ut Video FOURCC: %X\n", avctx->codec_tag);
return -1;
}
@@ -146,9 +119,8 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx)
utv->codec = CCodec::CreateInstance(UNFCC(avctx->codec_tag), "libavcodec");
/* Initialize Decoding */
- utv->codec->DecodeBegin(defined_fourcc ? defined_fourcc : UNFCC(info.original_format),
- avctx->width, avctx->height, CBGROSSWIDTH_WINDOWS, &info,
- sizeof(UtVideoExtra));
+ utv->codec->DecodeBegin(format, avctx->width, avctx->height,
+ CBGROSSWIDTH_WINDOWS, &info, sizeof(UtVideoExtra));
return 0;
}