aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice/decklink_common.cpp
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2017-02-18 02:33:05 +0100
committerMarton Balint <cus@passwd.hu>2017-02-26 22:47:33 +0100
commit48f8ad329010a93c323569cad695090a5930277b (patch)
treef3c6e15ec45c3afc7eae467bbe5d0b34f70c5815 /libavdevice/decklink_common.cpp
parente0eb0bdab94837e8557c139685fd997755b36178 (diff)
downloadffmpeg-48f8ad329010a93c323569cad695090a5930277b.tar.gz
avdevice/decklink_enc: add support to specify field order
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavdevice/decklink_common.cpp')
-rw-r--r--libavdevice/decklink_common.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index a3bc58dd6a..8b499c5640 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -130,9 +130,23 @@ static int decklink_select_input(AVFormatContext *avctx, BMDDeckLinkConfiguratio
return 0;
}
+static DECKLINK_BOOL field_order_eq(enum AVFieldOrder field_order, BMDFieldDominance bmd_field_order)
+{
+ if (field_order == AV_FIELD_UNKNOWN)
+ return true;
+ if ((field_order == AV_FIELD_TT || field_order == AV_FIELD_TB) && bmd_field_order == bmdUpperFieldFirst)
+ return true;
+ if ((field_order == AV_FIELD_BB || field_order == AV_FIELD_BT) && bmd_field_order == bmdLowerFieldFirst)
+ return true;
+ if (field_order == AV_FIELD_PROGRESSIVE && (bmd_field_order == bmdProgressiveFrame || bmd_field_order == bmdProgressiveSegmentedFrame))
+ return true;
+ return false;
+}
+
int ff_decklink_set_format(AVFormatContext *avctx,
int width, int height,
int tb_num, int tb_den,
+ enum AVFieldOrder field_order,
decklink_direction_t direction, int num)
{
struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
@@ -143,8 +157,8 @@ int ff_decklink_set_format(AVFormatContext *avctx,
int i = 1;
HRESULT res;
- av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, frame timing %d/%d, direction %d, mode number %d\n",
- width, height, tb_num, tb_den, direction, num);
+ av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, frame timing %d/%d, field order %d, direction %d, mode number %d\n",
+ width, height, tb_num, tb_den, field_order, direction, num);
if (ctx->duplex_mode) {
DECKLINK_BOOL duplex_supported = false;
@@ -187,18 +201,21 @@ int ff_decklink_set_format(AVFormatContext *avctx,
BMDTimeValue bmd_tb_num, bmd_tb_den;
int bmd_width = mode->GetWidth();
int bmd_height = mode->GetHeight();
+ BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance();
mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
AVRational mode_tb = av_make_q(bmd_tb_num, bmd_tb_den);
- if ((bmd_width == width && bmd_height == height &&
- !av_cmp_q(mode_tb, target_tb)) || i == num) {
+ if ((bmd_width == width &&
+ bmd_height == height &&
+ !av_cmp_q(mode_tb, target_tb) &&
+ field_order_eq(field_order, bmd_field_dominance)) || i == num) {
ctx->bmd_mode = mode->GetDisplayMode();
ctx->bmd_width = bmd_width;
ctx->bmd_height = bmd_height;
ctx->bmd_tb_den = bmd_tb_den;
ctx->bmd_tb_num = bmd_tb_num;
- ctx->bmd_field_dominance = mode->GetFieldDominance();
+ ctx->bmd_field_dominance = bmd_field_dominance;
av_log(avctx, AV_LOG_INFO, "Found Decklink mode %d x %d with rate %.2f%s\n",
bmd_width, bmd_height, 1/av_q2d(mode_tb),
(ctx->bmd_field_dominance==bmdLowerFieldFirst || ctx->bmd_field_dominance==bmdUpperFieldFirst)?"(i)":"");
@@ -230,7 +247,7 @@ int ff_decklink_set_format(AVFormatContext *avctx,
}
int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num) {
- return ff_decklink_set_format(avctx, 0, 0, 0, 0, direction, num);
+ return ff_decklink_set_format(avctx, 0, 0, 0, 0, AV_FIELD_UNKNOWN, direction, num);
}
int ff_decklink_list_devices(AVFormatContext *avctx)