summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-18 11:19:19 +0200
committerwm4 <wm4@nowhere>2012-08-20 15:36:04 +0200
commit53f6eba06cc5a44978c17faea1c2ec3ea8e0c117 (patch)
tree3e770abd8d110f2d8fa676fe306a4c62b57ce592 /libmpcodecs
parent6a26b4a66504f701baf35e58467e55aea28c0ad5 (diff)
downloadmpv-53f6eba06cc5a44978c17faea1c2ec3ea8e0c117.tar.bz2
mpv-53f6eba06cc5a44978c17faea1c2ec3ea8e0c117.tar.xz
vd_ffmpeg, demux_mng: allow general raw formats, fix MNG demuxer
Change vd_ffmpeg such that if sh_video->format is a mplayer pixel format, and there's no other codec information, try to play it as raw video. (The case of no codec information happens if the "generic" ffmpeg decoder is instantiated, which is tried last. This means clashes with actual existing formats are less likely.) demux_mng did not initialize all fields of the bih, which made vd_ffmpeg do invalid memory accesses when trying to copy the extradata. Also, use IMGFMT_RGB32 instead of creating the FourCC directly. (They should be the same, but what if mplayer changes the IMGFMT_* values.) This also fixes demux_rawvideo.
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/vd_ffmpeg.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index d4d816c52b..b30648b6f6 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -125,7 +125,8 @@ static int init(sh_video_t *sh)
struct lavc_param *lavc_param = &sh->opts->lavc_param;
AVCodecContext *avctx;
vd_ffmpeg_ctx *ctx;
- AVCodec *lavc_codec;
+ AVCodec *lavc_codec = NULL;
+ enum PixelFormat rawfmt = PIX_FMT_NONE;
int do_vis_debug = lavc_param->vismv ||
(lavc_param->debug & (FF_DEBUG_VIS_MB_TYPE | FF_DEBUG_VIS_QP));
@@ -140,17 +141,22 @@ static int init(sh_video_t *sh)
uninit(sh);
return 0;
}
- } else if (!sh->libav_codec_id) {
- mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "No Libav codec ID known. "
- "Generic lavc decoder is not applicable.\n");
- return 0;
- } else {
+ } else if (sh->libav_codec_id) {
lavc_codec = avcodec_find_decoder(sh->libav_codec_id);
if (!lavc_codec) {
mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Libavcodec has no decoder "
"for this codec\n");
+ uninit(sh);
return 0;
}
+ } else if (!IMGFMT_IS_HWACCEL(sh->format)) {
+ rawfmt = imgfmt2pixfmt(sh->format);
+ if (rawfmt != PIX_FMT_NONE)
+ lavc_codec = avcodec_find_decoder_by_name("rawvideo");
+ }
+ if (!lavc_codec) {
+ uninit(sh);
+ return 0;
}
sh->codecname = lavc_codec->long_name;
@@ -230,7 +236,11 @@ static int init(sh_video_t *sh)
if (lavc_param->gray)
avctx->flags |= CODEC_FLAG_GRAY;
avctx->flags2 |= lavc_param->fast;
- avctx->codec_tag = sh->format;
+ if (rawfmt == PIX_FMT_NONE) {
+ avctx->codec_tag = sh->format;
+ } else {
+ avctx->pix_fmt = rawfmt;
+ }
avctx->stream_codec_tag = sh->video.fccHandler;
avctx->idct_algo = lavc_param->idct_algo;
avctx->error_concealment = lavc_param->error_concealment;