History

avdevice/decklink: new option 'format_code' to set video format by fourCC

Matthias Hunstock committed 9 years ago

Commit b3a2ada1 parent 607bffb6 files · +28 −11Browse files

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

Unified · Split

libavdevice/decklink_common.cpp+12−4
@@ -33,6 +33,7 @@ extern "C" { · 32 unmodified lines
3333 #include "libavformat/avformat.h"
3434 #include "libavformat/internal.h"
3535 #include "libavutil/imgutils.h"
36+#include "libavutil/intreadwrite.h"
3637 #include "libavutil/bswap.h"
3738 }
3839
@@ -158,8 +159,8 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 119 unmodified lines
158159 int i = 1;
159160 HRESULT res;
160161
161− 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",
162− width, height, tb_num, tb_den, field_order, direction, num);
162+ 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, format code %s\n",
163+ width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)");
163164
164165 if (ctx->duplex_mode) {
165166 DECKLINK_BOOL duplex_supported = false;
@@ -196,12 +197,17 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 30 unmodified lines
196197 return AVERROR(EIO);
197198 }
198199
200+ char format_buf[] = " ";
201+ if (cctx->format_code)
202+ memcpy(format_buf, cctx->format_code, FFMIN(strlen(cctx->format_code), sizeof(format_buf)));
203+ BMDDisplayMode target_mode = (BMDDisplayMode)AV_RB32(format_buf);
199204 AVRational target_tb = av_make_q(tb_num, tb_den);
200205 ctx->bmd_mode = bmdModeUnknown;
201206 while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) {
202207 BMDTimeValue bmd_tb_num, bmd_tb_den;
203208 int bmd_width = mode->GetWidth();
204209 int bmd_height = mode->GetHeight();
210+ BMDDisplayMode bmd_mode = mode->GetDisplayMode();
205211 BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance();
206212
207213 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
@@ -210,8 +216,10 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 2 unmodified lines
210216 if ((bmd_width == width &&
211217 bmd_height == height &&
212218 !av_cmp_q(mode_tb, target_tb) &&
213− field_order_eq(field_order, bmd_field_dominance)) || i == num) {
214− ctx->bmd_mode = mode->GetDisplayMode();
219+ field_order_eq(field_order, bmd_field_dominance))
220+ || i == num
221+ || target_mode == bmd_mode) {
222+ ctx->bmd_mode = bmd_mode;
215223 ctx->bmd_width = bmd_width;
216224 ctx->bmd_height = bmd_height;
217225 ctx->bmd_tb_den = bmd_tb_den;

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