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
148 return false;148 return false;
149}149}
150 150
151int ff_decklink_set_format(AVFormatContext *avctx,151int ff_decklink_set_configs(AVFormatContext *avctx,
152 int width, int height,152 decklink_direction_t direction) {
153 int tb_num, int tb_den,
154 enum AVFieldOrder field_order,
155 decklink_direction_t direction, int num)
156{
157 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;153 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
158 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;154 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
159 BMDDisplayModeSupport support;
160 IDeckLinkDisplayModeIterator *itermode;
161 IDeckLinkDisplayMode *mode;
162 int i = 1;
163 HRESULT res;155 HRESULT res;
164 156
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
168 if (ctx->duplex_mode) {157 if (ctx->duplex_mode) {
169 DECKLINK_BOOL duplex_supported = false;158 DECKLINK_BOOL duplex_supported = false;
170 159
@@ -181,7 +170,6 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 10 unmodified lines
181 av_log(avctx, AV_LOG_WARNING, "Unable to set duplex mode, because it is not supported.\n");170 av_log(avctx, AV_LOG_WARNING, "Unable to set duplex mode, because it is not supported.\n");
182 }171 }
183 }172 }
184
185 if (direction == DIRECTION_IN) {173 if (direction == DIRECTION_IN) {
186 int ret;174 int ret;
187 ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection);175 ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection);
@@ -190,6 +178,28 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 2 unmodified lines
190 ret = decklink_select_input(avctx, bmdDeckLinkConfigVideoInputConnection);178 ret = decklink_select_input(avctx, bmdDeckLinkConfigVideoInputConnection);
191 if (ret < 0)179 if (ret < 0)
192 return ret;180 return ret;
181 }
182 return 0;
183}
184
185int 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) {
193 res = ctx->dli->GetDisplayModeIterator (&itermode);203 res = ctx->dli->GetDisplayModeIterator (&itermode);
194 } else {204 } else {
195 res = ctx->dlo->GetDisplayModeIterator (&itermode);205 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
134};134};
135 135
136HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);136HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
137int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t direction);
137int 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);138int 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);
138int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);139int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
139int ff_decklink_list_devices(AVFormatContext *avctx, struct AVDeviceInfoList *device_list, int show_inputs, int show_outputs);140int 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
916 goto error;916 goto error;
917 }917 }
918 918
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
919 if (mode_num > 0 || cctx->format_code) {925 if (mode_num > 0 || cctx->format_code) {
920 if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {926 if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
921 av_log(avctx, AV_LOG_ERROR, "Could not set mode number %d or format code %s for %s\n",927 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
162 return -1;162 return -1;
163 }163 }
164 164
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 }
165 if (ff_decklink_set_format(avctx, c->width, c->height,169 if (ff_decklink_set_format(avctx, c->width, c->height,
166 st->time_base.num, st->time_base.den, c->field_order)) {170 st->time_base.num, st->time_base.den, c->field_order)) {
167 av_log(avctx, AV_LOG_ERROR, "Unsupported video size, framerate or field order!"171 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