| 1095 | } |
| 1096 | |
| 1097 | av_cold int ff_decklink_read_header(AVFormatContext *avctx) |
| 1098 | { |
| 1099 | struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; |
| 1100 | struct decklink_ctx *ctx; |
| 1101 | class decklink_allocator *allocator; |
| 1102 | class decklink_input_callback *input_callback; |
| 1103 | AVStream *st; |
| 1104 | HRESULT result; |
| 1105 | int ret; |
| 1106 | |
| 1107 | ctx = (struct decklink_ctx *) av_mallocz(sizeof(struct decklink_ctx)); |
| 1108 | if (!ctx) |
| 1109 | return AVERROR(ENOMEM); |
| 1110 | ctx->list_devices = cctx->list_devices; |
| 1111 | ctx->list_formats = cctx->list_formats; |
| 1112 | ctx->enable_klv = cctx->enable_klv; |
| 1113 | ctx->teletext_lines = cctx->teletext_lines; |
| 1114 | ctx->preroll = cctx->preroll; |
| 1115 | ctx->duplex_mode = cctx->duplex_mode; |
| 1116 | if (cctx->tc_format > 0 && (unsigned int)cctx->tc_format < FF_ARRAY_ELEMS(decklink_timecode_format_map)) |
| 1117 | ctx->tc_format = decklink_timecode_format_map[cctx->tc_format]; |
| 1118 | if (cctx->video_input > 0 && (unsigned int)cctx->video_input < FF_ARRAY_ELEMS(decklink_video_connection_map)) |
| 1119 | ctx->video_input = decklink_video_connection_map[cctx->video_input]; |
| 1120 | if (cctx->audio_input > 0 && (unsigned int)cctx->audio_input < FF_ARRAY_ELEMS(decklink_audio_connection_map)) |
| 1121 | ctx->audio_input = decklink_audio_connection_map[cctx->audio_input]; |
| 1122 | ctx->audio_pts_source = cctx->audio_pts_source; |
| 1123 | ctx->video_pts_source = cctx->video_pts_source; |
| 1124 | ctx->draw_bars = cctx->draw_bars; |
| 1125 | ctx->signal_loss_action = cctx->signal_loss_action; |
| 1126 | if (!ctx->draw_bars && ctx->signal_loss_action == SIGNAL_LOSS_BARS) { |
| 1127 | ctx->signal_loss_action = SIGNAL_LOSS_NONE; |
| 1128 | av_log(avctx, AV_LOG_WARNING, "Setting signal_loss_action to none because draw_bars is false\n"); |
| 1129 | } |
| 1130 | if (!ctx->draw_bars && ctx->signal_loss_action != SIGNAL_LOSS_NONE) { |
| 1131 | av_log(avctx, AV_LOG_ERROR, "options draw_bars and signal_loss_action are mutually exclusive\n"); |
| 1132 | av_freep(&ctx); |
| 1133 | return AVERROR(EINVAL); |
| 1134 | } |
| 1135 | ctx->audio_depth = cctx->audio_depth; |
| 1136 | if (cctx->raw_format > 0 && (unsigned int)cctx->raw_format < FF_ARRAY_ELEMS(decklink_raw_format_map)) |
| 1137 | ctx->raw_format = decklink_raw_format_map[cctx->raw_format]; |
| 1138 | cctx->ctx = ctx; |
| 1139 | |
| 1140 | /* Check audio channel option for valid values: 2, 8 or 16 */ |
| 1141 | switch (cctx->audio_channels) { |
| 1142 | case 2: |
| 1143 | case 8: |
| 1144 | case 16: |
| 1145 | break; |
| 1146 | default: |
| 1147 | av_log(avctx, AV_LOG_ERROR, "Value of channels option must be one of 2, 8 or 16\n"); |
| 1148 | ret = AVERROR(EINVAL); |
| 1149 | goto error; |
| 1150 | } |
| 1151 | |
| 1152 | /* Check audio bit depth option for valid values: 16 or 32 */ |
| 1153 | switch (cctx->audio_depth) { |
| 1154 | case 16: |
nothing calls this directly
no test coverage detected