History

avdevice/decklink: refactor ff_decklink_set_format function

This is done to enable input format autodetection in decklink_dec.

Karthick J committed 9 years ago

Commit aa7b0321 parent 0e7865c4 files · +35 −14Browse files

Unified · Split

4 files
  1. libavdevice/decklink_common.cpp +24 −14
  2. libavdevice/decklink_common.h +1 −0
  3. libavdevice/decklink_dec.cpp +6 −0
  4. libavdevice/decklink_enc.cpp +4 −0
libavdevice/decklink_common.cpp+24−14
@@ -148,23 +148,12 @@ static DECKLINK_BOOL field_order_eq(enum AVFieldOrder field_order, BMDFieldDomin · 147 unmodified lines
148148 return false;
149149 }
150150
151−int ff_decklink_set_format(AVFormatContext *avctx,
152− int width, int height,
153− int tb_num, int tb_den,
154− enum AVFieldOrder field_order,
155− decklink_direction_t direction, int num)
156−{
151+int ff_decklink_set_configs(AVFormatContext *avctx,
152+ decklink_direction_t direction) {
157153 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
158154 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
159− BMDDisplayModeSupport support;
160− IDeckLinkDisplayModeIterator *itermode;
161− IDeckLinkDisplayMode *mode;
162− int i = 1;
163155 HRESULT res;
164156
165− 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",
166− width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)");
167−
168157 if (ctx->duplex_mode) {
169158 DECKLINK_BOOL duplex_supported = false;
170159
@@ -181,7 +170,6 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 10 unmodified lines
181170 av_log(avctx, AV_LOG_WARNING, "Unable to set duplex mode, because it is not supported.\n");
182171 }
183172 }
184−
185173 if (direction == DIRECTION_IN) {
186174 int ret;
187175 ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection);
@@ -190,6 +178,28 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 2 unmodified lines
190178 ret = decklink_select_input(avctx, bmdDeckLinkConfigVideoInputConnection);
191179 if (ret < 0)
192180 return ret;
181+ }
182+ return 0;
183+}
184+
185+int ff_decklink_set_format(AVFormatContext *avctx,
186+ int width, int height,
187+ int tb_num, int tb_den,
188+ enum AVFieldOrder field_order,
189+ decklink_direction_t direction, int num)
190+{
191+ struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
192+ struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
193+ BMDDisplayModeSupport support;
194+ IDeckLinkDisplayModeIterator *itermode;
195+ IDeckLinkDisplayMode *mode;
196+ int i = 1;
197+ HRESULT res;
198+
199+ 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",
200+ width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)");
201+
202+ if (direction == DIRECTION_IN) {
193203 res = ctx->dli->GetDisplayModeIterator (&itermode);
194204 } else {
195205 res = ctx->dlo->GetDisplayModeIterator (&itermode);
libavdevice/decklink_common.h+1−0
@@ -134,6 +134,7 @@ static const BMDVideoConnection decklink_video_connection_map[] = { · 133 unmodified lines
134134 };
135135
136136 HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
137+int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t direction);
137138 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 = DIRECTION_OUT, int num = 0);
138139 int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
139140 int ff_decklink_list_devices(AVFormatContext *avctx, struct AVDeviceInfoList *device_list, int show_inputs, int show_outputs);
libavdevice/decklink_dec.cpp+6−0
@@ -916,6 +916,12 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 915 unmodified lines
916916 goto error;
917917 }
918918
919+ if (ff_decklink_set_configs(avctx, DIRECTION_IN) < 0) {
920+ av_log(avctx, AV_LOG_ERROR, "Could not set input configuration\n");
921+ ret = AVERROR(EIO);
922+ goto error;
923+ }
924+
919925 if (mode_num > 0 || cctx->format_code) {
920926 if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
921927 av_log(avctx, AV_LOG_ERROR, "Could not set mode number %d or format code %s for %s\n",
libavdevice/decklink_enc.cpp+4−0
@@ -162,6 +162,10 @@ static int decklink_setup_video(AVFormatContext *avctx, AVStream *st) · 161 unmodified lines
162162 return -1;
163163 }
164164
165+ if (ff_decklink_set_configs(avctx, DIRECTION_OUT) < 0) {
166+ av_log(avctx, AV_LOG_ERROR, "Could not set output configuration\n");
167+ return -1;
168+ }
165169 if (ff_decklink_set_format(avctx, c->width, c->height,
166170 st->time_base.num, st->time_base.den, c->field_order)) {
167171 av_log(avctx, AV_LOG_ERROR, "Unsupported video size, framerate or field order!"

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