| @@ -531,30 +531,32 @@ static const AVClass av_codec_context_class = { · 530 unmodified lines |
| 531 | 531 | .child_class_next = codec_child_class_next, |
| 532 | 532 | }; |
| 533 | 533 | |
| 534 | +#if FF_API_ALLOC_CONTEXT |
| 534 | 535 | void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){ |
| 536 | + avcodec_get_context_defaults3(s, NULL); |
| 537 | +} |
| 538 | +#endif |
| 539 | + |
| 540 | +int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ |
| 535 | 541 | memset(s, 0, sizeof(AVCodecContext)); |
| 536 | 542 | |
| 537 | | − s->av_class= &av_codec_context_class; |
| 543 | + s->av_class = &av_codec_context_class; |
| 538 | 544 | |
| 539 | | − s->codec_type = codec_type; |
| 545 | + s->codec_type = codec ? codec->type : AVMEDIA_TYPE_UNKNOWN; |
| 540 | 546 | av_opt_set_defaults(s); |
| 541 | 547 | |
| 542 | | − s->time_base= (AVRational){0,1}; |
| 543 | | − s->get_buffer= avcodec_default_get_buffer; |
| 544 | | − s->release_buffer= avcodec_default_release_buffer; |
| 545 | | − s->get_format= avcodec_default_get_format; |
| 546 | | − s->execute= avcodec_default_execute; |
| 547 | | − s->execute2= avcodec_default_execute2; |
| 548 | | − s->sample_aspect_ratio= (AVRational){0,1}; |
| 549 | | − s->pix_fmt= PIX_FMT_NONE; |
| 550 | | − s->sample_fmt= AV_SAMPLE_FMT_NONE; |
| 551 | | − |
| 552 | | − s->reget_buffer= avcodec_default_reget_buffer; |
| 553 | | − s->reordered_opaque= AV_NOPTS_VALUE; |
| 554 | | −} |
| 555 | | − |
| 556 | | −int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ |
| 557 | | − avcodec_get_context_defaults2(s, codec ? codec->type : AVMEDIA_TYPE_UNKNOWN); |
| 548 | + s->time_base = (AVRational){0,1}; |
| 549 | + s->get_buffer = avcodec_default_get_buffer; |
| 550 | + s->release_buffer = avcodec_default_release_buffer; |
| 551 | + s->get_format = avcodec_default_get_format; |
| 552 | + s->execute = avcodec_default_execute; |
| 553 | + s->execute2 = avcodec_default_execute2; |
| 554 | + s->sample_aspect_ratio = (AVRational){0,1}; |
| 555 | + s->pix_fmt = PIX_FMT_NONE; |
| 556 | + s->sample_fmt = AV_SAMPLE_FMT_NONE; |
| 557 | + |
| 558 | + s->reget_buffer = avcodec_default_reget_buffer; |
| 559 | + s->reordered_opaque = AV_NOPTS_VALUE; |
| 558 | 560 | if(codec && codec->priv_data_size){ |
| 559 | 561 | if(!s->priv_data){ |
| 560 | 562 | s->priv_data= av_mallocz(codec->priv_data_size); |
| @@ -602,13 +604,11 @@ AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){ · 41 unmodified lines |
| 602 | 604 | |
| 603 | 605 | return avctx; |
| 604 | 606 | } |
| 605 | | −#endif |
| 606 | 607 | |
| 607 | 608 | void avcodec_get_context_defaults(AVCodecContext *s){ |
| 608 | 609 | avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN); |
| 609 | 610 | } |
| 610 | 611 | |
| 611 | | −#if FF_API_ALLOC_CONTEXT |
| 612 | 612 | AVCodecContext *avcodec_alloc_context(void){ |
| 613 | 613 | return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN); |
| 614 | 614 | } |