Changeset 967
- Timestamp:
- 10/23/08 14:31:55 (3 months ago)
- Files:
-
- branches/perian-1.1/FFusionCodec.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/perian-1.1/FFusionCodec.c
r960 r967 277 277 } 278 278 279 static enum PixelFormat FindPixFmtFromVideo(AVCodec *codec, AVCodecContext *avctx, Ptr data, int bufferSize) 280 { 281 AVCodecContext tmpContext; 282 AVFrame tmpFrame; 283 int got_picture; 284 enum PixelFormat pix_fmt; 285 286 avcodec_get_context_defaults2(&tmpContext, CODEC_TYPE_VIDEO); 287 tmpContext.width = avctx->width; 288 tmpContext.height = avctx->height; 289 tmpContext.codec_tag = avctx->codec_tag; 290 291 avcodec_open(&tmpContext, codec); 292 avcodec_decode_video(&tmpContext, &tmpFrame, &got_picture, (UInt8*)data, bufferSize); 293 pix_fmt = tmpContext.pix_fmt; 294 avcodec_close(&tmpContext); 295 296 return pix_fmt; 297 } 298 279 299 //--------------------------------------------------------------------------- 280 300 // Component Routines … … 536 556 Handle imgDescExt; 537 557 OSErr err = noErr; 538 enum PixelFormat pixelFormat = PIX_FMT_NONE;539 558 540 559 // We first open libavcodec library and the codec corresponding … … 790 809 err = featureUnsupported; 791 810 792 // this format doesn't have enough information in its headers793 // we have to decode the first frame794 if (glob->avContext->pix_fmt == PIX_FMT_NONE && p->bufferSize) {795 AVFrame temp;796 int got_picture;797 avcodec_open(glob->avContext, glob->avCodec);798 avcodec_decode_video(glob->avContext, &temp,799 &got_picture, (UInt8*)p->data, p->bufferSize);800 801 avcodec_close(glob->avContext);802 pixelFormat = glob->avContext->pix_fmt;803 }804 805 811 // some hooks into ffmpeg's buffer allocation to get frames in 806 812 // decode order without delay more easily … … 821 827 } 822 828 823 if (pixelFormat == PIX_FMT_NONE) 824 pixelFormat = glob->avContext->pix_fmt; 829 // this format doesn't have enough information in its headers 830 // we have to decode the first frame 831 if (glob->avContext->pix_fmt == PIX_FMT_NONE && p->bufferSize && p->data) 832 glob->avContext->pix_fmt = FindPixFmtFromVideo(glob->avCodec, glob->avContext, p->data, p->bufferSize); 825 833 } 826 834 … … 861 869 862 870 if (!err) { 863 switch ( pixelFormat)871 switch (glob->avContext->pix_fmt) 864 872 { 865 873 case PIX_FMT_BGR24:
