[FFmpeg-devel] [PATCH] dv codec : allow selecting between 720p60 and 720p50 profiles based on framerate
Steve Jiekak
devaureshy at gmail.com
Wed Dec 3 12:48:46 CET 2014
Signed-off-by: Steve Jiekak <devaureshy at gmail.com>
---
libavcodec/dv_profile.c | 14 +++++++++++---
libavcodec/dv_profile.h | 2 +-
libavcodec/dvenc.c | 2 +-
libavformat/dv.c | 2 +-
libavformat/dvenc.c | 3 ++-
5 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/libavcodec/dv_profile.c b/libavcodec/dv_profile.c
index b301cbf..5c4e23c 100644
--- a/libavcodec/dv_profile.c
+++ b/libavcodec/dv_profile.c
@@ -312,18 +312,26 @@ const AVDVProfile *av_dv_frame_profile(const AVDVProfile *sys,
}
const AVDVProfile *av_dv_codec_profile(int width, int height,
- enum AVPixelFormat pix_fmt)
+ enum AVPixelFormat pix_fmt,
+ AVRational time_base)
{
+ const AVDVProfile *p = NULL;
#if CONFIG_DVPROFILE
int i;
+ /* frame rate is necessary to select between 720p50 and 720p60 profiles */
+ int validtimebase = time_base.num == 0 || time_base.den == 0;
for (i = 0; i < FF_ARRAY_ELEMS(dv_profiles); i++)
if (height == dv_profiles[i].height &&
pix_fmt == dv_profiles[i].pix_fmt &&
width == dv_profiles[i].width)
- return &dv_profiles[i];
+ {
+ p = &dv_profiles[i];
+ if( !validtimebase || av_div_q(p->time_base, time_base).num == 1 )
+ return p;
+ }
#endif
- return NULL;
+ return p;
}
diff --git a/libavcodec/dv_profile.h b/libavcodec/dv_profile.h
index d4437c9..c595f21 100644
--- a/libavcodec/dv_profile.h
+++ b/libavcodec/dv_profile.h
@@ -81,6 +81,6 @@ const AVDVProfile *av_dv_frame_profile(const AVDVProfile *sys,
/**
* Get a DV profile for the provided stream parameters.
*/
-const AVDVProfile *av_dv_codec_profile(int width, int height, enum AVPixelFormat pix_fmt);
+const AVDVProfile *av_dv_codec_profile(int width, int height, enum AVPixelFormat pix_fmt, AVRational time_base);
#endif /* AVCODEC_DV_PROFILE_H */
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 5d810e3..2163757 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -47,7 +47,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
PixblockDSPContext pdsp;
int ret;
- s->sys = av_dv_codec_profile(avctx->width, avctx->height, avctx->pix_fmt);
+ s->sys = av_dv_codec_profile(avctx->width, avctx->height, avctx->pix_fmt, avctx->time_base);
if (!s->sys) {
av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. "
"Valid DV profiles are:\n",
diff --git a/libavformat/dv.c b/libavformat/dv.c
index 095966c..3d32910 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -423,7 +423,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
{
// FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
const AVDVProfile *sys = av_dv_codec_profile(c->vst->codec->width, c->vst->codec->height,
- c->vst->codec->pix_fmt);
+ c->vst->codec->pix_fmt, c->vst->codec->time_base);
int64_t offset;
int64_t size = avio_size(s->pb) - s->data_offset;
int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size;
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 18fdf9f..1a30a15 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -337,7 +337,8 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
goto bail_out;
}
}
- c->sys = av_dv_codec_profile(vst->codec->width, vst->codec->height, vst->codec->pix_fmt);
+ c->sys = av_dv_codec_profile(vst->codec->width, vst->codec->height,
+ vst->codec->pix_fmt, vst->codec->time_base);
if (!c->sys)
goto bail_out;
--
1.7.9.5
More information about the ffmpeg-devel
mailing list