[FFmpeg-devel] select different dv profiles using framerates

2014-12-03 Thread Steve Jiekak

720p60 and 720p50 are currently not differentiable during profile selection.
If set to a profile value the framerate will be used as the last criteria.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] dv codec : allow selecting between 720p60 and 720p50 profiles based on framerate

2014-12-03 Thread Steve Jiekak

Signed-off-by: Steve Jiekak 
---
 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

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] add av_dv_codec_profile2 : uses framerate to select best matching profile. default on first matching profile

2014-12-03 Thread Steve Jiekak
Signed-off-by: Steve Jiekak 
---
 doc/APIchanges  |3 +++
 libavcodec/dv_profile.c |   27 +++
 libavcodec/dv_profile.h |6 ++
 libavcodec/version.h|2 +-
 4 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5915ad3..a81c3b9 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2014-12-03 - xxx - lavc 56.14.100 - dv_profile.h
+  Add av_dv_codec_profile2().
+
 2014-11-21 - xxx - lavu 54.15.100 - dict.h
Add av_dict_get_string().
 
diff --git a/libavcodec/dv_profile.c b/libavcodec/dv_profile.c
index b301cbf..362afe4 100644
--- a/libavcodec/dv_profile.c
+++ b/libavcodec/dv_profile.c
@@ -311,19 +311,38 @@ const AVDVProfile *av_dv_frame_profile(const AVDVProfile 
*sys,
 return ff_dv_frame_profile(NULL, sys, frame, buf_size);
 }
 
-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)
 {
 #if CONFIG_DVPROFILE
+return av_dv_codec_profile2(width, height, pix_fmt, (AVRational){0, 0});
+#endif
+
+return NULL;
+}
+
+const AVDVProfile *av_dv_codec_profile2(int width, int height,
+   enum AVPixelFormat pix_fmt,
+   AVRational frame_rate)
+{
+const AVDVProfile *p = NULL;
+#if CONFIG_DVPROFILE
 int i;
+/* frame rate is necessary to select between 720p50 and 720p60 profiles */
+int invalid_framerate = frame_rate.num == 0 || frame_rate.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];
+{
+if( !invalid_framerate || av_div_q(dv_profiles[i].time_base, 
frame_rate).num == 1 )
+return &dv_profiles[i];
+
+if(!p)
+p = &dv_profiles[i];
+}
 #endif
 
-return NULL;
+return p;
 }
 
diff --git a/libavcodec/dv_profile.h b/libavcodec/dv_profile.h
index d4437c9..d22ad26 100644
--- a/libavcodec/dv_profile.h
+++ b/libavcodec/dv_profile.h
@@ -83,4 +83,10 @@ const AVDVProfile *av_dv_frame_profile(const AVDVProfile 
*sys,
  */
 const AVDVProfile *av_dv_codec_profile(int width, int height, enum 
AVPixelFormat pix_fmt);
 
+/**
+ * Get a DV profile for the provided stream parameters.
+ * The frame rate is used as a best-effort parameter.
+ */
+const AVDVProfile *av_dv_codec_profile2(int width, int height, enum 
AVPixelFormat pix_fmt, AVRational frame_rate);
+
 #endif /* AVCODEC_DV_PROFILE_H */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 23443ed..ef439d6 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 56
-#define LIBAVCODEC_VERSION_MINOR  13
+#define LIBAVCODEC_VERSION_MINOR  14
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
1.7.9.5

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] replaced av_dv_codec_profile by av_dv_codec_profile2 in encoder and dv muxers

2014-12-03 Thread Steve Jiekak

Signed-off-by: Steve Jiekak 
---
 libavcodec/dvenc.c |2 +-
 libavformat/dv.c   |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 5d810e3..7061508 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_profile2(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..4b8593d 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -422,8 +422,8 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
DVDemuxContext *c,
int64_t timestamp, int flags)
 {
 // 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);
+const AVDVProfile *sys = av_dv_codec_profile2(c->vst->codec->width, 
c->vst->codec->height,
+ 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;
-- 
1.7.9.5

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] revised patches for dv profile

2014-12-04 Thread Steve Jiekak

- fixed defect with invalid framerate
- included libavformat\dvenc.c in second patch

Steve
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] add av_dv_codec_profile2 : uses framerate to select best matching profile. default on first matching profile

2014-12-04 Thread Steve Jiekak
Signed-off-by: Steve Jiekak 
---
 doc/APIchanges  |3 +++
 libavcodec/dv_profile.c |   24 ++--
 libavcodec/dv_profile.h |6 ++
 libavcodec/version.h|2 +-
 4 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 66b1278..df87465 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2014-12-04 - xxx - lavc 56.14.100 - dv_profile.h
+  Add av_dv_codec_profile2().
+
  8< - FFmpeg 2.5 was cut here  8< -
 
 2014-11-21 - ab922f9 - lavu 54.15.100 - dict.h
diff --git a/libavcodec/dv_profile.c b/libavcodec/dv_profile.c
index b301cbf..e336e08 100644
--- a/libavcodec/dv_profile.c
+++ b/libavcodec/dv_profile.c
@@ -315,15 +315,35 @@ const AVDVProfile *av_dv_codec_profile(int width, int 
height,
enum AVPixelFormat pix_fmt)
 {
 #if CONFIG_DVPROFILE
+return av_dv_codec_profile2(width, height, pix_fmt, (AVRational){0, 0});
+#endif
+
+return NULL;
+}
+
+const AVDVProfile *av_dv_codec_profile2(int width, int height,
+   enum AVPixelFormat pix_fmt,
+   AVRational frame_rate)
+{
+const AVDVProfile *p = NULL;
+#if CONFIG_DVPROFILE
 int i;
+/* frame rate is necessary to select between 720p50 and 720p60 profiles */
+int invalid_framerate = frame_rate.num == 0 || frame_rate.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];
+{
+if( invalid_framerate || av_div_q(dv_profiles[i].time_base, 
frame_rate).num == 1 )
+return &dv_profiles[i];
+
+if(!p)
+p = &dv_profiles[i];
+}
 #endif
 
-return NULL;
+return p;
 }
 
diff --git a/libavcodec/dv_profile.h b/libavcodec/dv_profile.h
index d4437c9..d22ad26 100644
--- a/libavcodec/dv_profile.h
+++ b/libavcodec/dv_profile.h
@@ -83,4 +83,10 @@ const AVDVProfile *av_dv_frame_profile(const AVDVProfile 
*sys,
  */
 const AVDVProfile *av_dv_codec_profile(int width, int height, enum 
AVPixelFormat pix_fmt);
 
+/**
+ * Get a DV profile for the provided stream parameters.
+ * The frame rate is used as a best-effort parameter.
+ */
+const AVDVProfile *av_dv_codec_profile2(int width, int height, enum 
AVPixelFormat pix_fmt, AVRational frame_rate);
+
 #endif /* AVCODEC_DV_PROFILE_H */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 23443ed..ef439d6 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 56
-#define LIBAVCODEC_VERSION_MINOR  13
+#define LIBAVCODEC_VERSION_MINOR  14
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
1.7.0.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] replaced av_dv_codec_profile by av_dv_codec_profile2 in encoder and dv muxers

2014-12-04 Thread Steve Jiekak
Signed-off-by: Steve Jiekak 
---
 libavcodec/dvenc.c  |2 +-
 libavformat/dv.c|4 ++--
 libavformat/dvenc.c |3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 5d810e3..7061508 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_profile2(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..4b8593d 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -422,8 +422,8 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
DVDemuxContext *c,
int64_t timestamp, int flags)
 {
 // 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);
+const AVDVProfile *sys = av_dv_codec_profile2(c->vst->codec->width, 
c->vst->codec->height,
+ 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..e99ac3c 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_profile2(vst->codec->width, vst->codec->height,
+  vst->codec->pix_fmt, vst->codec->time_base);
 if (!c->sys)
 goto bail_out;
 
-- 
1.7.0.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel