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
143 int i = 1;143 int i = 1;
144 HRESULT res;144 HRESULT res;
145 145
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
146 if (ctx->duplex_mode) {149 if (ctx->duplex_mode) {
147 DECKLINK_BOOL duplex_supported = false;150 DECKLINK_BOOL duplex_supported = false;
148 151
@@ -178,11 +181,7 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 29 unmodified lines
178 return AVERROR(EIO);181 return AVERROR(EIO);
179 }182 }
180 183
181 184 AVRational target_tb = av_make_q(tb_num, tb_den);
182 if (tb_num == 1) {
183 tb_num *= 1000;
184 tb_den *= 1000;
185 }
186 ctx->bmd_mode = bmdModeUnknown;185 ctx->bmd_mode = bmdModeUnknown;
187 while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) {186 while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) {
188 BMDTimeValue bmd_tb_num, bmd_tb_den;187 BMDTimeValue bmd_tb_num, bmd_tb_den;
@@ -190,9 +189,10 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 1 unmodified line
190 int bmd_height = mode->GetHeight();189 int bmd_height = mode->GetHeight();
191 190
192 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);191 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
192 AVRational mode_tb = av_make_q(bmd_tb_num, bmd_tb_den);
193 193
194 if ((bmd_width == width && bmd_height == height &&194 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) {
196 ctx->bmd_mode = mode->GetDisplayMode();196 ctx->bmd_mode = mode->GetDisplayMode();
197 ctx->bmd_width = bmd_width;197 ctx->bmd_width = bmd_width;
198 ctx->bmd_height = bmd_height;198 ctx->bmd_height = bmd_height;
@@ -200,7 +200,7 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 1 unmodified line
200 ctx->bmd_tb_num = bmd_tb_num;200 ctx->bmd_tb_num = bmd_tb_num;
201 ctx->bmd_field_dominance = mode->GetFieldDominance();201 ctx->bmd_field_dominance = mode->GetFieldDominance();
202 av_log(avctx, AV_LOG_INFO, "Found Decklink mode %d x %d with rate %.2f%s\n",202 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),
204 (ctx->bmd_field_dominance==bmdLowerFieldFirst || ctx->bmd_field_dominance==bmdUpperFieldFirst)?"(i)":"");204 (ctx->bmd_field_dominance==bmdLowerFieldFirst || ctx->bmd_field_dominance==bmdUpperFieldFirst)?"(i)":"");
205 }205 }
206 206

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