| 2087 | } |
| 2088 | |
| 2089 | static int has_codec_parameters(const AVStream *st, const char **errmsg_ptr) |
| 2090 | { |
| 2091 | const FFStream *const sti = cffstream(st); |
| 2092 | const AVCodecContext *const avctx = sti->avctx; |
| 2093 | |
| 2094 | #define FAIL(errmsg) do { \ |
| 2095 | if (errmsg_ptr) \ |
| 2096 | *errmsg_ptr = errmsg; \ |
| 2097 | return 0; \ |
| 2098 | } while (0) |
| 2099 | |
| 2100 | if ( avctx->codec_id == AV_CODEC_ID_NONE |
| 2101 | && avctx->codec_type != AVMEDIA_TYPE_DATA) |
| 2102 | FAIL("unknown codec"); |
| 2103 | switch (avctx->codec_type) { |
| 2104 | case AVMEDIA_TYPE_AUDIO: |
| 2105 | if (!avctx->frame_size && determinable_frame_size(avctx)) |
| 2106 | FAIL("unspecified frame size"); |
| 2107 | if (sti->info->found_decoder >= 0 && |
| 2108 | avctx->sample_fmt == AV_SAMPLE_FMT_NONE) |
| 2109 | FAIL("unspecified sample format"); |
| 2110 | if (!avctx->sample_rate) |
| 2111 | FAIL("unspecified sample rate"); |
| 2112 | if (!avctx->ch_layout.nb_channels) |
| 2113 | FAIL("unspecified number of channels"); |
| 2114 | if (sti->info->found_decoder >= 0 && !sti->nb_decoded_frames && avctx->codec_id == AV_CODEC_ID_DTS) |
| 2115 | FAIL("no decodable DTS frames"); |
| 2116 | break; |
| 2117 | case AVMEDIA_TYPE_VIDEO: |
| 2118 | if (!avctx->width) |
| 2119 | FAIL("unspecified size"); |
| 2120 | if (sti->info->found_decoder >= 0 && avctx->pix_fmt == AV_PIX_FMT_NONE) |
| 2121 | FAIL("unspecified pixel format"); |
| 2122 | if (st->codecpar->codec_id == AV_CODEC_ID_RV30 || st->codecpar->codec_id == AV_CODEC_ID_RV40) |
| 2123 | if (!st->sample_aspect_ratio.num && !st->codecpar->sample_aspect_ratio.num && !sti->codec_info_nb_frames) |
| 2124 | FAIL("no frame in rv30/40 and no sar"); |
| 2125 | break; |
| 2126 | case AVMEDIA_TYPE_SUBTITLE: |
| 2127 | if (avctx->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE && !avctx->width) |
| 2128 | FAIL("unspecified size"); |
| 2129 | break; |
| 2130 | case AVMEDIA_TYPE_DATA: |
| 2131 | if (avctx->codec_id == AV_CODEC_ID_NONE) return 1; |
| 2132 | } |
| 2133 | |
| 2134 | return 1; |
| 2135 | } |
| 2136 | |
| 2137 | /* returns 1 or 0 if or if not decoded data was returned, or a negative error */ |
| 2138 | static int try_decode_frame(AVFormatContext *s, AVStream *st, |
no test coverage detected