Deprecate avcodec_get_context_defaults/avcodec_get_context_defaults2
Unified · Split
| @@ -4234,8 +4234,8 @@ static int parse_ffconfig(const char *filename) · 4233 unmodified lines | |||
| 4234 | } | 4234 | } |
| 4235 | 4235 | ||
| 4236 | stream->fmt = avserver_guess_format(NULL, stream->filename, NULL); | 4236 | stream->fmt = avserver_guess_format(NULL, stream->filename, NULL); |
| 4237 | avcodec_get_context_defaults2(&video_enc, AVMEDIA_TYPE_VIDEO); | 4237 | avcodec_get_context_defaults3(&video_enc, NULL); |
| 4238 | avcodec_get_context_defaults2(&audio_enc, AVMEDIA_TYPE_AUDIO); | 4238 | avcodec_get_context_defaults3(&audio_enc, NULL); |
| 4239 | audio_id = CODEC_ID_NONE; | 4239 | audio_id = CODEC_ID_NONE; |
| 4240 | video_id = CODEC_ID_NONE; | 4240 | video_id = CODEC_ID_NONE; |
| 4241 | if (stream->fmt) { | 4241 | if (stream->fmt) { |
| @@ -3592,19 +3592,31 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); · 3591 unmodified lines | |||
| 3592 | */ | 3592 | */ |
| 3593 | const char *av_get_profile_name(const AVCodec *codec, int profile); | 3593 | const char *av_get_profile_name(const AVCodec *codec, int profile); |
| 3594 | 3594 | ||
| 3595 | #if FF_API_ALLOC_CONTEXT | ||
| 3595 | /** | 3596 | /** |
| 3596 | * Set the fields of the given AVCodecContext to default values. | 3597 | * Set the fields of the given AVCodecContext to default values. |
| 3597 | * | 3598 | * |
| 3598 | * @param s The AVCodecContext of which the fields should be set to default values. | 3599 | * @param s The AVCodecContext of which the fields should be set to default values. |
| 3600 | * @deprecated use avcodec_get_context_defaults3 | ||
| 3599 | */ | 3601 | */ |
| 3602 | attribute_deprecated | ||
| 3600 | void avcodec_get_context_defaults(AVCodecContext *s); | 3603 | void avcodec_get_context_defaults(AVCodecContext *s); |
| 3601 | 3604 | ||
| 3602 | /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! | 3605 | /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! |
| 3603 | * we WILL change its arguments and name a few times! */ | 3606 | * we WILL change its arguments and name a few times! */ |
| 3607 | attribute_deprecated | ||
| 3604 | void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); | 3608 | void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); |
| 3609 | #endif | ||
| 3605 | 3610 | ||
| 3606 | /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! | 3611 | /** |
| 3607 | * we WILL change its arguments and name a few times! */ | 3612 | * Set the fields of the given AVCodecContext to default values corresponding |
| 3613 | * to the given codec (defaults may be codec-dependent). | ||
| 3614 | * | ||
| 3615 | * Do not call this function if a non-NULL codec has been passed | ||
| 3616 | * to avcodec_alloc_context3() that allocated this AVCodecContext. | ||
| 3617 | * If codec is non-NULL, it is illegal to call avcodec_open2() with a | ||
| 3618 | * different codec on this AVCodecContext. | ||
| 3619 | */ | ||
| 3608 | int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec); | 3620 | int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec); |
| 3609 | 3621 | ||
| 3610 | #if FF_API_ALLOC_CONTEXT | 3622 | #if FF_API_ALLOC_CONTEXT |
| @@ -531,30 +531,32 @@ static const AVClass av_codec_context_class = { · 530 unmodified lines | |||
| 531 | .child_class_next = codec_child_class_next, | 531 | .child_class_next = codec_child_class_next, |
| 532 | }; | 532 | }; |
| 533 | 533 | ||
| 534 | #if FF_API_ALLOC_CONTEXT | ||
| 534 | void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){ | 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 | memset(s, 0, sizeof(AVCodecContext)); | 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 | av_opt_set_defaults(s); | 546 | av_opt_set_defaults(s); |
| 541 | 547 | ||
| 542 | s->time_base= (AVRational){0,1}; | 548 | s->time_base = (AVRational){0,1}; |
| 543 | s->get_buffer= avcodec_default_get_buffer; | 549 | s->get_buffer = avcodec_default_get_buffer; |
| 544 | s->release_buffer= avcodec_default_release_buffer; | 550 | s->release_buffer = avcodec_default_release_buffer; |
| 545 | s->get_format= avcodec_default_get_format; | 551 | s->get_format = avcodec_default_get_format; |
| 546 | s->execute= avcodec_default_execute; | 552 | s->execute = avcodec_default_execute; |
| 547 | s->execute2= avcodec_default_execute2; | 553 | s->execute2 = avcodec_default_execute2; |
| 548 | s->sample_aspect_ratio= (AVRational){0,1}; | 554 | s->sample_aspect_ratio = (AVRational){0,1}; |
| 549 | s->pix_fmt= PIX_FMT_NONE; | 555 | s->pix_fmt = PIX_FMT_NONE; |
| 550 | s->sample_fmt= AV_SAMPLE_FMT_NONE; | 556 | s->sample_fmt = AV_SAMPLE_FMT_NONE; |
| 551 | 557 | ||
| 552 | s->reget_buffer= avcodec_default_reget_buffer; | 558 | s->reget_buffer = avcodec_default_reget_buffer; |
| 553 | s->reordered_opaque= AV_NOPTS_VALUE; | 559 | 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); | ||
| 558 | if(codec && codec->priv_data_size){ | 560 | if(codec && codec->priv_data_size){ |
| 559 | if(!s->priv_data){ | 561 | if(!s->priv_data){ |
| 560 | s->priv_data= av_mallocz(codec->priv_data_size); | 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 | return avctx; | 605 | return avctx; |
| 604 | } | 606 | } |
| 605 | #endif | ||
| 606 | 607 | ||
| 607 | void avcodec_get_context_defaults(AVCodecContext *s){ | 608 | void avcodec_get_context_defaults(AVCodecContext *s){ |
| 608 | avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN); | 609 | avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN); |
| 609 | } | 610 | } |
| 610 | 611 | ||
| 611 | #if FF_API_ALLOC_CONTEXT | ||
| 612 | AVCodecContext *avcodec_alloc_context(void){ | 612 | AVCodecContext *avcodec_alloc_context(void){ |
| 613 | return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN); | 613 | return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN); |
| 614 | } | 614 | } |