summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vd_ffmpeg.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-07-24 09:01:47 +0300
committerUoti Urpala <uau@mplayer2.org>2012-07-24 09:01:47 +0300
commit5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2 (patch)
tree44a68334360af69b358dafc0cecf773ca5871ecc /libmpcodecs/vd_ffmpeg.c
parent65b24e46a1c2f26688458cf16a11733e96da0f22 (diff)
downloadmpv-5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2.tar.bz2
mpv-5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2.tar.xz
video, audio: use lavc decoders without codecs.conf entries
Add support for using libavcodec decoders that do not have entries in codecs.conf. This is currently only used with demux_lavf, and the codec selection is based on codec_id returned by libavformat. Also modify codec-related terminal output somewhat to make it use information from libavcodec and avoid excessively long default output. The new any-lavc-codec support is implemented with codecs.conf entries that invoke vd_ffmpeg/ad_ffmpeg without directly specifying any libavcodec codec name. In this mode, the decoders now instead select the libavcodec codec based on codec_id previously set by demux_lavf (if any). These new "generic" codecs.conf entries specify "status buggy", so that they're tried after any specific entries with higher-priority status. Add new directive "anyinput" to codecs.conf syntax. This means the entry will always match regardless of fourcc. This is used for the above new codecs.conf entries (so the driver always gets to decide whether to accept the input, and will fail init() if it can't find a suitable codec in libavcodec). Remove parsing support for the obsolete codecs.conf directive "cpuflags". This directive has not had any effect and has not been used in default codecs.conf since many years ago. Shorten codec-related terminal output. When using libavcodec decoders, show the libavcodec long_name field rather than codecs.conf "info" field as the name of the codec. Stop showing the codecs.conf entry name and "vfm/afm" name by default, as these are rarely needed; they're now in verbose output only. Show "VIDEO:" line at VO initialization rather than at demuxer open. This didn't really belong in demuxer code; the new location may show more accurate values (known after decoder has been opened) and works right if video track is changed after initial demuxer open. The vd.c changes (primarily done for terminal output changes) remove round-to-even behavior from code setting dimensions based on aspect ratio. I hope nothing depended on this; at least the even values were not consistently guaranteed anyway, as the rounding code did not run if the video file did not specify a nonzero aspect value.
Diffstat (limited to 'libmpcodecs/vd_ffmpeg.c')
-rw-r--r--libmpcodecs/vd_ffmpeg.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 5a45fef6d8..b34b5b5593 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -43,11 +43,12 @@
#include "osdep/numcores.h"
static const vd_info_t info = {
- "FFmpeg's libavcodec codec family",
+ "libavcodec video codecs",
"ffmpeg",
- "A'rpi",
- "A'rpi, Michael, Alex",
- "native codecs"
+ "",
+ "",
+ "native codecs",
+ .print_name = "libavcodec",
};
#include "libavcodec/avcodec.h"
@@ -129,14 +130,32 @@ static int init(sh_video_t *sh)
ctx = sh->context = talloc_zero(NULL, vd_ffmpeg_ctx);
- lavc_codec = avcodec_find_decoder_by_name(sh->codec->dll);
- if (!lavc_codec) {
- mp_tmsg(MSGT_DECVIDEO, MSGL_ERR,
- "Cannot find codec '%s' in libavcodec...\n", sh->codec->dll);
- uninit(sh);
+ if (sh->codec->dll) {
+ lavc_codec = avcodec_find_decoder_by_name(sh->codec->dll);
+ if (!lavc_codec) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR,
+ "Cannot find codec '%s' in libavcodec...\n",
+ sh->codec->dll);
+ 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 {
+ 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");
+ return 0;
+ }
}
+ sh->codecname = lavc_codec->long_name;
+ if (!sh->codecname)
+ sh->codecname = lavc_codec->name;
+
if (sh->opts->vd_use_slices
&& (lavc_codec->capabilities & CODEC_CAP_DRAW_HORIZ_BAND)
&& !do_vis_debug)
@@ -191,7 +210,7 @@ static int init(sh_video_t *sh)
if (lavc_param->threads > 1) {
ctx->do_dr1 = false;
ctx->do_slices = false;
- mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Asking decoder to use "
+ mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Asking decoder to use "
"%d threads if supported.\n", lavc_param->threads);
}
@@ -320,8 +339,7 @@ static int init(sh_video_t *sh)
uninit(sh);
return 0;
}
- mp_msg(MSGT_DECVIDEO, MSGL_V, "INFO: libavcodec init OK!\n");
- return 1; //mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, IMGFMT_YV12);
+ return 1;
}
static void uninit(sh_video_t *sh)
@@ -329,6 +347,7 @@ static void uninit(sh_video_t *sh)
vd_ffmpeg_ctx *ctx = sh->context;
AVCodecContext *avctx = ctx->avctx;
+ sh->codecname = NULL;
if (sh->opts->lavc_param.vstats && avctx->coded_frame) {
for (int i = 1; i < 32; i++)
mp_msg(MSGT_DECVIDEO, MSGL_INFO,