[FFmpeg-devel] [PATCH/RFC] Make dvvideo encoder less lenient wrt resolution and pixel format
Tomas Härdin
tomas.hardin
Fri Dec 11 09:17:49 CET 2009
Good morning
I've been using FFmpeg for a while and noticed somewhat recently that
the dvvideo encoder accepts any resolution or pixel format in
dvvideo_init(), which later might cause dvvideo_encode_frame() to fail.
I believe this behavior is wrong since most other encoders are quite
strict about which settings are allowed when they're opened - for
instance h261 and h263.
The only reason I can see for not performing this check is if one is
encoding to a container which allows switching DV profile mid-stream,
which means supporting local headers, resolution changes and frame rate
changes, which some containers might. However, this assumes the user
does not know a valid resolution/pixel format combination with which to
open the encoder in the first place. I find it unlikely that this would
be the case very often.
Anyway, I've pasted a simple patch at the end of this message which adds
a simple check in a separate init function for the encoder to correct
this behavior. Please comment or simply merge.
Thanks for listening
/Tomas H?rdin
Index: libavcodec/dv.c
===================================================================
--- libavcodec/dv.c (revision 20796)
+++ libavcodec/dv.c (working copy)
@@ -398,6 +398,15 @@
return 0;
}
+static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) {
+ if(!ff_dv_codec_profile(avctx)) {
+ av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s
video\n", avctx->width, avctx->height,
avcodec_get_pix_fmt_name(avctx->pix_fmt));
+ return -1;
+ }
+
+ return dvvideo_init(avctx);
+}
+
// #define VLC_DEBUG
// #define printf(...) av_log(NULL, AV_LOG_ERROR, __VA_ARGS__)
@@ -1326,7 +1335,7 @@
CODEC_TYPE_VIDEO,
CODEC_ID_DVVIDEO,
sizeof(DVVideoContext),
- dvvideo_init,
+ dvvideo_init_encoder,
dvvideo_encode_frame,
.pix_fmts = (const enum PixelFormat[]) {PIX_FMT_YUV411P,
PIX_FMT_YUV422P, PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
More information about the ffmpeg-devel
mailing list