diff options
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/ad_ffmpeg.c | 39 | ||||
-rw-r--r-- | libmpcodecs/dec_audio.c | 51 | ||||
-rw-r--r-- | libmpcodecs/dec_video.c | 15 | ||||
-rw-r--r-- | libmpcodecs/mpc_info.h | 1 | ||||
-rw-r--r-- | libmpcodecs/vd.c | 28 | ||||
-rw-r--r-- | libmpcodecs/vd_ffmpeg.c | 43 |
6 files changed, 115 insertions, 62 deletions
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 0bfc5e5f0a..a20689eab8 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -38,11 +38,12 @@ static const ad_info_t info = { - "FFmpeg/libavcodec audio decoders", + "libavcodec audio decoders", "ffmpeg", - "Nick Kurshev", - "ffmpeg.sf.net", - "" + "", + "", + "", + .print_name = "libavcodec", }; LIBAD_EXTERN(ffmpeg) @@ -112,16 +113,31 @@ static int init(sh_audio_t *sh_audio) AVCodecContext *lavc_context; AVCodec *lavc_codec; - mp_msg(MSGT_DECAUDIO, MSGL_V, "FFmpeg's libavcodec audio codec\n"); - - lavc_codec = avcodec_find_decoder_by_name(sh_audio->codec->dll); - if (!lavc_codec) { - mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, - "Cannot find codec '%s' in libavcodec...\n", - sh_audio->codec->dll); + if (sh_audio->codec->dll) { + lavc_codec = avcodec_find_decoder_by_name(sh_audio->codec->dll); + if (!lavc_codec) { + mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, + "Cannot find codec '%s' in libavcodec...\n", + sh_audio->codec->dll); + return 0; + } + } else if (!sh_audio->libav_codec_id) { + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "No Libav codec ID known. " + "Generic lavc decoder is not applicable.\n"); return 0; + } else { + lavc_codec = avcodec_find_decoder(sh_audio->libav_codec_id); + if (!lavc_codec) { + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Libavcodec has no decoder " + "for this codec\n"); + return 0; + } } + sh_audio->codecname = lavc_codec->long_name; + if (!sh_audio->codecname) + sh_audio->codecname = lavc_codec->name; + struct priv *ctx = talloc_zero(NULL, struct priv); sh_audio->context = ctx; lavc_context = avcodec_alloc_context3(lavc_codec); @@ -217,6 +233,7 @@ static int init(sh_audio_t *sh_audio) static void uninit(sh_audio_t *sh) { + sh->codecname = NULL; struct priv *ctx = sh->context; if (!ctx) return; diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c index 2445649075..59c05a187a 100644 --- a/libmpcodecs/dec_audio.c +++ b/libmpcodecs/dec_audio.c @@ -96,14 +96,12 @@ static int init_audio_codec(sh_audio_t *sh_audio) sh_audio->audio_out_minsize, base_size, sh_audio->a_buffer_size); sh_audio->a_buffer = av_mallocz(sh_audio->a_buffer_size); - if (!sh_audio->a_buffer) { - mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Cannot allocate audio out buffer.\n"); - return 0; - } + if (!sh_audio->a_buffer) + abort(); sh_audio->a_buffer_len = 0; if (!sh_audio->ad_driver->init(sh_audio)) { - mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "ADecoder init failed :(\n"); + mp_tmsg(MSGT_DECAUDIO, MSGL_V, "ADecoder init failed :(\n"); uninit_audio(sh_audio); // free buffers return 0; } @@ -111,7 +109,8 @@ static int init_audio_codec(sh_audio_t *sh_audio) sh_audio->initialized = 1; if (!sh_audio->channels || !sh_audio->samplerate) { - mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "Unknown/missing audio format -> no sound\n"); + mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Audio decoder did not specify " + "audio format!\n"); uninit_audio(sh_audio); // free buffers return 0; } @@ -119,18 +118,6 @@ static int init_audio_codec(sh_audio_t *sh_audio) if (!sh_audio->o_bps) sh_audio->o_bps = sh_audio->channels * sh_audio->samplerate * sh_audio->samplesize; - - mp_msg(MSGT_DECAUDIO, MSGL_INFO, - "AUDIO: %d Hz, %d ch, %s, %3.1f kbit/%3.2f%% (ratio: %d->%d)\n", - sh_audio->samplerate, sh_audio->channels, - af_fmt2str_short(sh_audio->sample_format), - sh_audio->i_bps * 8 * 0.001, - ((float) sh_audio->i_bps / sh_audio->o_bps) * 100.0, - sh_audio->i_bps, sh_audio->o_bps); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, - "ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n", - sh_audio->i_bps * 8, sh_audio->samplerate, sh_audio->channels); - return 1; } @@ -181,13 +168,12 @@ static int init_audio(sh_audio_t *sh_audio, char *codecname, char *afm, } // it's available, let's try to init! // init() - mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Opening audio decoder: [%s] %s\n", + mp_tmsg(MSGT_DECAUDIO, MSGL_V, "Opening audio decoder: [%s] %s\n", mpadec->info->short_name, mpadec->info->name); sh_audio->ad_driver = mpadec; if (!init_audio_codec(sh_audio)) { - mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, - "Could not open audio decoder %s.\n", - mpadec->info->short_name); + mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "Audio decoder init failed for " + "codecs.conf entry \"%s\".\n", sh_audio->codec->name); continue; // try next... } // Yeah! We got it! @@ -251,8 +237,25 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list, return 0; // failed } - mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Selected audio codec: [%s] afm: %s (%s)\n", - sh_audio->codec->name, sh_audio->codec->drv, sh_audio->codec->info); + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Selected audio codec: %s [%s]\n", + sh_audio->codecname ? sh_audio->codecname : sh_audio->codec->info, + sh_audio->ad_driver->info->print_name ? + sh_audio->ad_driver->info->print_name : + sh_audio->ad_driver->info->short_name); + mp_tmsg(MSGT_DECAUDIO, MSGL_V, + "Audio codecs.conf entry: %s (%s) afm: %s\n", + sh_audio->codec->name, sh_audio->codec->info, sh_audio->codec->drv); + mp_msg(MSGT_DECAUDIO, MSGL_INFO, + "AUDIO: %d Hz, %d ch, %s, %3.1f kbit/%3.2f%% (ratio: %d->%d)\n", + sh_audio->samplerate, sh_audio->channels, + af_fmt2str_short(sh_audio->sample_format), + sh_audio->i_bps * 8 * 0.001, + ((float) sh_audio->i_bps / sh_audio->o_bps) * 100.0, + sh_audio->i_bps, sh_audio->o_bps); + mp_msg(MSGT_IDENTIFY, MSGL_INFO, + "ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n", + sh_audio->i_bps * 8, sh_audio->samplerate, sh_audio->channels); + return 1; // success } diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c index 14cf029fbe..baa8467c1e 100644 --- a/libmpcodecs/dec_video.c +++ b/libmpcodecs/dec_video.c @@ -310,13 +310,14 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm, // init() const struct vd_functions *vd = sh_video->vd_driver; - mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Opening video decoder: [%s] %s\n", + mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Opening video decoder: [%s] %s\n", vd->info->short_name, vd->info->name); // clear vf init error, it is no longer relevant if (sh_video->vf_initialized < 0) sh_video->vf_initialized = 0; if (!vd->init(sh_video)) { - mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "VDecoder init failed :(\n"); + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Video decoder init failed for " + "codecs.conf entry \"%s\".\n", sh_video->codec->name); sh_video->disp_w = orig_w; sh_video->disp_h = orig_h; if (sh_video->bih) { @@ -389,8 +390,14 @@ int init_best_video_codec(sh_video_t *sh_video, char **video_codec_list, return 0; // failed } - mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Selected video codec: [%s] vfm: %s (%s)\n", - sh_video->codec->name, sh_video->codec->drv, sh_video->codec->info); + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Selected video codec: %s [%s]\n", + sh_video->codecname ? sh_video->codecname : sh_video->codec->info, + sh_video->vd_driver->info->print_name ? + sh_video->vd_driver->info->print_name : + sh_video->vd_driver->info->short_name); + mp_tmsg(MSGT_DECVIDEO, MSGL_V, + "Video codecs.conf entry: %s (%s) vfm: %s\n", + sh_video->codec->name, sh_video->codec->info, sh_video->codec->drv); return 1; // success } diff --git a/libmpcodecs/mpc_info.h b/libmpcodecs/mpc_info.h index 45139947cb..de1631cad8 100644 --- a/libmpcodecs/mpc_info.h +++ b/libmpcodecs/mpc_info.h @@ -31,6 +31,7 @@ struct mp_codec_info const char *author; /* any additional comments */ const char *comment; + const char *print_name; }; #define CONTROL_OK 1 diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c index 5a96e07783..a883f257b5 100644 --- a/libmpcodecs/vd.c +++ b/libmpcodecs/vd.c @@ -125,6 +125,11 @@ int mpcodecs_config_vo2(sh_video_t *sh, int w, int h, if (h) sh->disp_h = h; + mp_msg(MSGT_DECVIDEO, MSGL_INFO, + "VIDEO: %dx%d %5.3f fps %5.1f kbps (%4.1f kB/s)\n", + sh->disp_w, sh->disp_h, sh->fps, sh->i_bps * 0.008, + sh->i_bps / 1000.0); + if (!sh->disp_w || !sh->disp_h) return 0; @@ -293,22 +298,23 @@ int mpcodecs_config_vo2(sh_video_t *sh, int w, int h, } } if (sh->aspect > 0.01) { - int w; - mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Movie-Aspect is %.2f:1 - prescaling to correct movie aspect.\n", - sh->aspect); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", sh->aspect); - w = (int) ((float) screen_size_y * sh->aspect); - w += w % 2; // round + int w = screen_size_y * sh->aspect; + int h = screen_size_y; // we don't like horizontal downscale || user forced width: if (w < screen_size_x || opts->screen_size_xy > 8) { - screen_size_y = - (int) ((float) screen_size_x * (1.0 / sh->aspect)); - screen_size_y += screen_size_y % 2; // round - } else - screen_size_x = w; // keep new width + w = screen_size_x; + h = screen_size_x / sh->aspect; + } + if (abs(screen_size_x - w) >= 4 || abs(screen_size_y - h) >= 4) { + screen_size_x = w; + screen_size_y = h; + mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Aspect ratio is %.2f:1 - " + "scaling to correct movie aspect.\n", sh->aspect); + } } else { - mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Movie-Aspect is undefined - no prescaling applied.\n"); + mp_tmsg(MSGT_CPLAYER, MSGL_V, "Movie-Aspect is undefined - no prescaling applied.\n"); } } 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, |