Changeset 410
- Timestamp:
- 04/12/07 02:28:56 (2 years ago)
- Files:
-
- trunk/FFissionCodec/FFissionDecoder.cpp (modified) (3 diffs)
- trunk/FFissionCodec/FFissionDecoder.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/FFissionCodec/FFissionDecoder.cpp
r409 r410 186 186 CodecID codecID = GetCodecID(inInputFormat.mFormatID); 187 187 188 avCodec = avcodec_find_decoder(codecID);189 190 188 // check to make sure the input format is legal 191 if (av Codec== NULL) {189 if (avcodec_find_decoder(codecID) == NULL) { 192 190 Codecprintf(NULL, "Unsupported input format id %4.4s\n", &inInputFormat.mFormatID); 193 191 CODEC_THROW(kAudioCodecUnsupportedFormatError); 194 192 } 195 193 194 // tell our base class about the new format 195 FFissionCodec::SetCurrentInputFormat(inInputFormat); 196 } 197 198 void FFissionDecoder::OpenAVCodec() 199 { 200 if (!mIsInitialized) 201 CODEC_THROW(kAudioCodecStateError); 202 203 CodecID codecID = GetCodecID(mInputFormat.mFormatID); 204 205 avCodec = avcodec_find_decoder(codecID); 206 196 207 avcodec_get_context_defaults(avContext); 197 208 198 avContext->sample_rate = inInputFormat.mSampleRate;199 avContext->channels = inInputFormat.mChannelsPerFrame;200 avContext->block_align = inInputFormat.mBytesPerPacket;201 avContext->frame_size = inInputFormat.mFramesPerPacket;202 avContext->bits_per_sample = inInputFormat.mBitsPerChannel;209 avContext->sample_rate = mInputFormat.mSampleRate; 210 avContext->channels = mInputFormat.mChannelsPerFrame; 211 avContext->block_align = mInputFormat.mBytesPerPacket; 212 avContext->frame_size = mInputFormat.mFramesPerPacket; 213 avContext->bits_per_sample = mInputFormat.mBitsPerChannel; 203 214 204 215 if (avContext->sample_rate == 0) { … … 209 220 210 221 if (magicCookie) { 211 SetupExtradata( inInputFormat.mFormatID);222 SetupExtradata(mInputFormat.mFormatID); 212 223 } 213 224 214 225 if (avcodec_open(avContext, avCodec)) { 215 226 Codecprintf(NULL, "error opening audio avcodec\n"); 216 217 227 avCodec = NULL; 218 CODEC_THROW(kAudioCodecIllegalOperationError); 219 } 220 221 // tell our base class about the new format 222 FFissionCodec::SetCurrentInputFormat(inInputFormat); 228 CODEC_THROW(kAudioCodecUnsupportedFormatError); 229 } 223 230 } 224 231 … … 275 282 UInt32 ans = kAudioCodecProduceOutputPacketSuccess; 276 283 277 if (!mIsInitialized) 284 if (!avCodec) 285 OpenAVCodec(); 286 287 if (!mIsInitialized || !avCodec) 278 288 CODEC_THROW(kAudioCodecStateError); 279 289 trunk/FFissionCodec/FFissionDecoder.h
r408 r410 49 49 private: 50 50 void SetupExtradata(OSType formatID); 51 void OpenAVCodec(); 51 52 52 53 UInt32 kIntPCMOutFormatFlag;
