Unified · Split
| @@ -92,7 +92,7 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile) · 91 unmodified lines | |||
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | static void ffat_update_ctx(AVCodecContext *avctx) | 95 | static int ffat_update_ctx(AVCodecContext *avctx) |
| 96 | { | 96 | { |
| 97 | ATDecodeContext *at = avctx->priv_data; | 97 | ATDecodeContext *at = avctx->priv_data; |
| 98 | UInt32 size = sizeof(unsigned); | 98 | UInt32 size = sizeof(unsigned); |
| @@ -118,10 +118,23 @@ static void ffat_update_ctx(AVCodecContext *avctx) · 19 unmodified lines | |||
| 118 | if (!AudioConverterGetProperty(at->converter, | 118 | if (!AudioConverterGetProperty(at->converter, |
| 119 | kAudioConverterCurrentOutputStreamDescription, | 119 | kAudioConverterCurrentOutputStreamDescription, |
| 120 | &size, &out_format)) { | 120 | &size, &out_format)) { |
| 121 | if (out_format.mFramesPerPacket) | 121 | if (out_format.mFramesPerPacket) { |
| 122 | avctx->frame_size = out_format.mFramesPerPacket; | 122 | avctx->frame_size = out_format.mFramesPerPacket; |
| 123 | } else { | ||
| 124 | /* The doc on mFramesPerPacket says: | ||
| 125 | * For formats with a variable number of frames per packet, such as | ||
| 126 | * Ogg Vorbis, set this field to 0. | ||
| 127 | * Looks like it means for decoding. There is no known case that | ||
| 128 | * mFramesPerPacket is zero for encoding. Use a default value for safety. | ||
| 129 | */ | ||
| 130 | avctx->frame_size = 1024; | ||
| 131 | av_log(avctx, AV_LOG_WARNING, "Missing mFramesPerPacket\n"); | ||
| 132 | } | ||
| 123 | if (out_format.mBytesPerPacket && avctx->codec_id == AV_CODEC_ID_ILBC) | 133 | if (out_format.mBytesPerPacket && avctx->codec_id == AV_CODEC_ID_ILBC) |
| 124 | avctx->block_align = out_format.mBytesPerPacket; | 134 | avctx->block_align = out_format.mBytesPerPacket; |
| 135 | } else { | ||
| 136 | av_log(avctx, AV_LOG_ERROR, "Get OutputStreamDescription failed\n"); | ||
| 137 | return AVERROR_EXTERNAL; | ||
| 125 | } | 138 | } |
| 126 | 139 | ||
| 127 | at->frame_size = avctx->frame_size; | 140 | at->frame_size = avctx->frame_size; |
| @@ -130,6 +143,8 @@ static void ffat_update_ctx(AVCodecContext *avctx) · 2 unmodified lines | |||
| 130 | at->pkt_size *= 1024; | 143 | at->pkt_size *= 1024; |
| 131 | avctx->frame_size *= 1024; | 144 | avctx->frame_size *= 1024; |
| 132 | } | 145 | } |
| 146 | |||
| 147 | return 0; | ||
| 133 | } | 148 | } |
| 134 | 149 | ||
| 135 | static int read_descr(GetByteContext *gb, int *tag) | 150 | static int read_descr(GetByteContext *gb, int *tag) |
| @@ -236,6 +251,7 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx) · 100 unmodified lines | |||
| 236 | { | 251 | { |
| 237 | ATDecodeContext *at = avctx->priv_data; | 252 | ATDecodeContext *at = avctx->priv_data; |
| 238 | OSStatus status; | 253 | OSStatus status; |
| 254 | int ret; | ||
| 239 | 255 | ||
| 240 | AudioStreamBasicDescription in_format = { | 256 | AudioStreamBasicDescription in_format = { |
| 241 | .mSampleRate = avctx->sample_rate, | 257 | .mSampleRate = avctx->sample_rate, |
| @@ -432,7 +448,9 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx) · 190 unmodified lines | |||
| 432 | } | 448 | } |
| 433 | } | 449 | } |
| 434 | 450 | ||
| 435 | ffat_update_ctx(avctx); | 451 | ret = ffat_update_ctx(avctx); |
| 452 | if (ret < 0) | ||
| 453 | return ret; | ||
| 436 | 454 | ||
| 437 | #if !TARGET_OS_IPHONE && defined(__MAC_10_9) | 455 | #if !TARGET_OS_IPHONE && defined(__MAC_10_9) |
| 438 | if (at->mode == kAudioCodecBitRateControlMode_Variable && avctx->rc_max_rate) { | 456 | if (at->mode == kAudioCodecBitRateControlMode_Variable && avctx->rc_max_rate) { |