ffmpegagent:
> From: softworkz
>
> - Add avcodec_decode_subtitle3 which takes subtitle frames,
> serving as compatibility shim to legacy subtitle decoding
> - Add additional methods for conversion between old and new API
This commit message is completely wrong.
>
> Signed-off-by: softworkz
> ---
> libavcodec/avcodec.h| 8 +-
> libavcodec/codec_desc.c | 11 +++
> libavcodec/codec_desc.h | 8 ++
> libavcodec/decode.c | 56 ++--
> libavcodec/internal.h | 22 +
> libavcodec/utils.c | 184
> 6 files changed, 280 insertions(+), 9 deletions(-)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index fe5a83cf85..9d59f6e840 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1675,7 +1675,7 @@ typedef struct AVCodecContext {
>
> /**
> * Header containing style information for text subtitles.
> - * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
> + * For AV_SUBTITLE_FMT_ASS subtitle type, it should contain the whole ASS
> * [Script Info] and [V4+ Styles] section, plus the [Events] line and
> * the Format line following. It shouldn't include any Dialogue line.
> * - encoding: Set/allocated/freed by user (before avcodec_open2())
> @@ -2415,7 +2415,10 @@ int avcodec_close(AVCodecContext *avctx);
> * Free all allocated data in the given subtitle struct.
> *
> * @param sub AVSubtitle to free.
> + *
> + * @deprecated Use the regular frame based encode and decode APIs instead.
> */
> +attribute_deprecated
> void avsubtitle_free(AVSubtitle *sub);
>
> /**
> @@ -2508,7 +2511,10 @@ enum AVChromaLocation avcodec_chroma_pos_to_enum(int
> xpos, int ypos);
> * must be freed with avsubtitle_free if *got_sub_ptr is set.
> * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed,
> otherwise, it is nonzero.
> * @param[in] avpkt The input AVPacket containing the input buffer.
> + *
> + * @deprecated Use the new decode API (avcodec_send_packet,
> avcodec_receive_frame) instead.
> */
> +attribute_deprecated
> int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
> int *got_sub_ptr,
> AVPacket *avpkt);
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 0974ee03de..e48e4532ba 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -3548,3 +3548,14 @@ enum AVMediaType avcodec_get_type(enum AVCodecID
> codec_id)
> const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
> return desc ? desc->type : AVMEDIA_TYPE_UNKNOWN;
> }
> +
> +enum AVSubtitleType avcodec_descriptor_get_subtitle_format(const
> AVCodecDescriptor *codec_descriptor)
> +{
> +if(codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)
> +return AV_SUBTITLE_FMT_BITMAP;
> +
> +if(codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
> +return AV_SUBTITLE_FMT_ASS;
> +
> +return AV_SUBTITLE_FMT_UNKNOWN;
> +}
> diff --git a/libavcodec/codec_desc.h b/libavcodec/codec_desc.h
> index 126b52df47..ba68d24e0e 100644
> --- a/libavcodec/codec_desc.h
> +++ b/libavcodec/codec_desc.h
> @@ -121,6 +121,14 @@ const AVCodecDescriptor *avcodec_descriptor_next(const
> AVCodecDescriptor *prev);
> */
> const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
>
> +/**
> + * Return subtitle format from a codec descriptor
> + *
> + * @param codec_descriptor codec descriptor
> + * @return the subtitle type (e.g. bitmap, text)
> + */
> +enum AVSubtitleType avcodec_descriptor_get_subtitle_format(const
> AVCodecDescriptor *codec_descriptor);
> +
> /**
> * @}
> */
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 0912f86a14..ab8a6ea6ff 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -576,6 +576,39 @@ static int decode_receive_frame_internal(AVCodecContext
> *avctx, AVFrame *frame)
> return ret;
> }
>
> +static int decode_subtitle2_priv(AVCodecContext *avctx, AVSubtitle *sub,
> + int *got_sub_ptr, AVPacket *avpkt);
> +
> +static int decode_subtitle_shim(AVCodecContext *avctx, AVFrame *frame,
> AVPacket *avpkt)
> +{
> +int ret, got_sub_ptr = 0;
> +AVSubtitle subtitle = { 0 };
> +
> +if (frame->buf[0])
> +return AVERROR(EAGAIN);
> +
> +av_frame_unref(frame);
> +
> +ret = decode_subtitle2_priv(avctx, , _sub_ptr, avpkt);
> +
> +if (ret >= 0 && got_sub_ptr) {
> +frame->type = AVMEDIA_TYPE_SUBTITLE;
> +frame->format = subtitle.format;
> +ret = av_frame_get_buffer2(frame, 0);
> +
> +if (ret >= 0)
> +ret = ff_frame_put_subtitle(frame, );
> +
> +frame->width = avctx->width;
> +frame->height = avctx->height;
> +frame->pkt_dts = avpkt->dts;
> +}
> +
> +avsubtitle_free();
> +
> +return ret;
> +}
> +
> int