Showing the changes to libavdevice/decklink_common.cpp (1 of 6 files). Show all
Unified · Split
| @@ -33,6 +33,7 @@ extern "C" { · 32 unmodified lines | |||
| 33 | #include "libavformat/avformat.h" | 33 | #include "libavformat/avformat.h" |
| 34 | #include "libavformat/internal.h" | 34 | #include "libavformat/internal.h" |
| 35 | #include "libavutil/imgutils.h" | 35 | #include "libavutil/imgutils.h" |
| 36 | #include "libavutil/intreadwrite.h" | ||
| 36 | #include "libavutil/bswap.h" | 37 | #include "libavutil/bswap.h" |
| 37 | } | 38 | } |
| 38 | 39 | ||
| @@ -158,8 +159,8 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 119 unmodified lines | |||
| 158 | int i = 1; | 159 | int i = 1; |
| 159 | HRESULT res; | 160 | HRESULT res; |
| 160 | 161 | ||
| 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 | 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", |
| 162 | width, height, tb_num, tb_den, field_order, direction, num); | 163 | width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)"); |
| 163 | 164 | ||
| 164 | if (ctx->duplex_mode) { | 165 | if (ctx->duplex_mode) { |
| 165 | DECKLINK_BOOL duplex_supported = false; | 166 | DECKLINK_BOOL duplex_supported = false; |
| @@ -196,12 +197,17 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 30 unmodified lines | |||
| 196 | return AVERROR(EIO); | 197 | return AVERROR(EIO); |
| 197 | } | 198 | } |
| 198 | 199 | ||
| 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); | ||
| 199 | AVRational target_tb = av_make_q(tb_num, tb_den); | 204 | AVRational target_tb = av_make_q(tb_num, tb_den); |
| 200 | ctx->bmd_mode = bmdModeUnknown; | 205 | ctx->bmd_mode = bmdModeUnknown; |
| 201 | while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) { | 206 | while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) { |
| 202 | BMDTimeValue bmd_tb_num, bmd_tb_den; | 207 | BMDTimeValue bmd_tb_num, bmd_tb_den; |
| 203 | int bmd_width = mode->GetWidth(); | 208 | int bmd_width = mode->GetWidth(); |
| 204 | int bmd_height = mode->GetHeight(); | 209 | int bmd_height = mode->GetHeight(); |
| 210 | BMDDisplayMode bmd_mode = mode->GetDisplayMode(); | ||
| 205 | BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance(); | 211 | BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance(); |
| 206 | 212 | ||
| 207 | mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den); | 213 | mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den); |
| @@ -210,8 +216,10 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 2 unmodified lines | |||
| 210 | if ((bmd_width == width && | 216 | if ((bmd_width == width && |
| 211 | bmd_height == height && | 217 | bmd_height == height && |
| 212 | !av_cmp_q(mode_tb, target_tb) && | 218 | !av_cmp_q(mode_tb, target_tb) && |
| 213 | field_order_eq(field_order, bmd_field_dominance)) || i == num) { | 219 | field_order_eq(field_order, bmd_field_dominance)) |
| 214 | ctx->bmd_mode = mode->GetDisplayMode(); | 220 | || i == num |
| 221 | || target_mode == bmd_mode) { | ||
| 222 | ctx->bmd_mode = bmd_mode; | ||
| 215 | ctx->bmd_width = bmd_width; | 223 | ctx->bmd_width = bmd_width; |
| 216 | ctx->bmd_height = bmd_height; | 224 | ctx->bmd_height = bmd_height; |
| 217 | ctx->bmd_tb_den = bmd_tb_den; | 225 | ctx->bmd_tb_den = bmd_tb_den; |