Skip to content

Commit

Permalink
vd_lavc: by default, output all frames, even corrupted ones
Browse files Browse the repository at this point in the history
Set the flag CODEC_FLAG_OUTPUT_CORRUPT by default. Note that there is
also CODEC_FLAG2_SHOW_ALL, which is older, but this seems to be ffmpeg
only.

Note that whether you want this enabled depends on the user. Some might
prefer that only good frames are output, while others want the decoder
to try as hard as possible to output _anything_. Since mplayer/mpv is
rather the kind of player that tries hard instead of being "clever", set
the new default to override libavcodec's default.

A nice way to test this is switching video tracks. Since mpv doesn't
wait for the next key frame, it'll start feeding the decoder with a
packet from the middle of the stream.
  • Loading branch information
wm4 committed Dec 29, 2013
1 parent 15f38b8 commit 392856e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions DOCS/man/en/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2631,6 +2631,11 @@ OPTIONS

``--vd--lavc-o=debug=pict``

``--vd-lavc-show-all=<yes|no>``
Show even broken/corrupt frames (default: yes). If this option is set to
no, libavcodec won't output frames that were either decoded before an
initial keyframe was decoded, or frames that are recognized as corrupted.

``--vd-lavc-skiploopfilter=<skipvalue> (H.264 only)``
Skips the loop filter (AKA deblocking) during H.264 decoding. Since
the filtered frame is supposed to be used as reference for decoding
Expand Down
1 change: 1 addition & 0 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ const struct MPOpts mp_default_opts = {
.allow_mimetype = 1,
},
.lavc_param = {
.show_all = 1,
.check_hw_profile = 1,
},
.input = {
Expand Down
1 change: 1 addition & 0 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ typedef struct MPOpts {

struct lavc_param {
int fast;
int show_all;
char *skip_loop_filter_str;
char *skip_idct_str;
char *skip_frame_str;
Expand Down
10 changes: 10 additions & 0 deletions video/decode/vd_lavc.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ static void uninit(struct dec_video *vd);

const m_option_t lavc_decode_opts_conf[] = {
OPT_FLAG_CONSTANTS("fast", lavc_param.fast, 0, 0, CODEC_FLAG2_FAST),
OPT_FLAG("show-all", lavc_param.show_all, 0),
OPT_STRING("skiploopfilter", lavc_param.skip_loop_filter_str, 0),
OPT_STRING("skipidct", lavc_param.skip_idct_str, 0),
OPT_STRING("skipframe", lavc_param.skip_frame_str, 0),
Expand Down Expand Up @@ -421,6 +422,15 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
avctx->flags |= lavc_param->bitexact;

avctx->flags2 |= lavc_param->fast;
if (lavc_param->show_all) {
#ifdef CODEC_FLAG2_SHOW_ALL
avctx->flags2 |= CODEC_FLAG2_SHOW_ALL; // ffmpeg only?
#endif
#ifdef CODEC_FLAG_OUTPUT_CORRUPT
avctx->flags |= CODEC_FLAG_OUTPUT_CORRUPT; // added with Libav 10
#endif
}

avctx->skip_loop_filter = str2AVDiscard(vd, lavc_param->skip_loop_filter_str);
avctx->skip_idct = str2AVDiscard(vd, lavc_param->skip_idct_str);
avctx->skip_frame = str2AVDiscard(vd, lavc_param->skip_frame_str);
Expand Down

0 comments on commit 392856e

Please sign in to comment.