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 | 33 | #include "libavformat/avformat.h" |
| 34 | 34 | #include "libavformat/internal.h" |
| 35 | 35 | #include "libavutil/imgutils.h" |
| 36 | +#include "libavutil/intreadwrite.h" | |
| 36 | 37 | #include "libavutil/bswap.h" |
| 37 | 38 | } |
| 38 | 39 | |
| @@ -158,8 +159,8 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 119 unmodified lines | ||
| 158 | 159 | int i = 1; |
| 159 | 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 | − 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)"); | |
| 163 | 164 | |
| 164 | 165 | if (ctx->duplex_mode) { |
| 165 | 166 | DECKLINK_BOOL duplex_supported = false; |
| @@ -196,12 +197,17 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 30 unmodified lines | ||
| 196 | 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 | 204 | AVRational target_tb = av_make_q(tb_num, tb_den); |
| 200 | 205 | ctx->bmd_mode = bmdModeUnknown; |
| 201 | 206 | while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) { |
| 202 | 207 | BMDTimeValue bmd_tb_num, bmd_tb_den; |
| 203 | 208 | int bmd_width = mode->GetWidth(); |
| 204 | 209 | int bmd_height = mode->GetHeight(); |
| 210 | + BMDDisplayMode bmd_mode = mode->GetDisplayMode(); | |
| 205 | 211 | BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance(); |
| 206 | 212 | |
| 207 | 213 | mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den); |
| @@ -210,8 +216,10 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 2 unmodified lines | ||
| 210 | 216 | if ((bmd_width == width && |
| 211 | 217 | bmd_height == height && |
| 212 | 218 | !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; | |
| 215 | 223 | ctx->bmd_width = bmd_width; |
| 216 | 224 | ctx->bmd_height = bmd_height; |
| 217 | 225 | ctx->bmd_tb_den = bmd_tb_den; |