History

decklink: enhancement: format selection with AVRational v2

When finding a video mode based on frame size and frame rate, use AVRational methods instead of simple comparison. Add debug information.

Matthias Hunstock committed 10 years ago

Commit d8ee02a1 parent 8431a6e1 file · +7 −7Browse files

Showing the changes to libavdevice/decklink_common.cpp (1 of 1 file). Show all

Unified · Split

libavdevice/decklink_common.cpp+7−7
@@ -143,6 +143,9 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 142 unmodified lines
143143 int i = 1;
144144 HRESULT res;
145145
146+ 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",
147+ width, height, tb_num, tb_den, direction, num);
148+
146149 if (ctx->duplex_mode) {
147150 DECKLINK_BOOL duplex_supported = false;
148151
@@ -178,11 +181,7 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 29 unmodified lines
178181 return AVERROR(EIO);
179182 }
180183
181−
182− if (tb_num == 1) {
183− tb_num *= 1000;
184− tb_den *= 1000;
185− }
184+ AVRational target_tb = av_make_q(tb_num, tb_den);
186185 ctx->bmd_mode = bmdModeUnknown;
187186 while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) {
188187 BMDTimeValue bmd_tb_num, bmd_tb_den;
@@ -190,9 +189,10 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 1 unmodified line
190189 int bmd_height = mode->GetHeight();
191190
192191 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
192+ AVRational mode_tb = av_make_q(bmd_tb_num, bmd_tb_den);
193193
194194 if ((bmd_width == width && bmd_height == height &&
195− bmd_tb_num == tb_num && bmd_tb_den == tb_den) || i == num) {
195+ !av_cmp_q(mode_tb, target_tb)) || i == num) {
196196 ctx->bmd_mode = mode->GetDisplayMode();
197197 ctx->bmd_width = bmd_width;
198198 ctx->bmd_height = bmd_height;
@@ -200,7 +200,7 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 1 unmodified line
200200 ctx->bmd_tb_num = bmd_tb_num;
201201 ctx->bmd_field_dominance = mode->GetFieldDominance();
202202 av_log(avctx, AV_LOG_INFO, "Found Decklink mode %d x %d with rate %.2f%s\n",
203− bmd_width, bmd_height, (float)bmd_tb_den/(float)bmd_tb_num,
203+ bmd_width, bmd_height, 1/av_q2d(mode_tb),
204204 (ctx->bmd_field_dominance==bmdLowerFieldFirst || ctx->bmd_field_dominance==bmdUpperFieldFirst)?"(i)":"");
205205 }
206206

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t