[FFmpeg-devel] [PATCH v2] libavcodec/dnxhd: added dnxhr profiles
Mark Reid
mindmark at gmail.com
Thu Jul 7 01:40:17 EEST 2016
On Wed, Jul 6, 2016 at 2:31 AM, Rostislav Pehlivanov
<atomnuker at gmail.com> wrote:
> On 6 July 2016 at 03:46, Mark Reid <mindmark at gmail.com> wrote:
>
>> ---
>> libavcodec/avcodec.h | 7 +++++++
>> libavcodec/codec_desc.c | 1 +
>> libavcodec/dnxhddec.c | 20 ++++++++++++++++++++
>> libavcodec/profiles.c | 10 ++++++++++
>> libavcodec/profiles.h | 1 +
>> 5 files changed, 39 insertions(+)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 39713ed..8f84fd0 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -3165,6 +3165,13 @@ typedef struct AVCodecContext {
>> #define FF_PROFILE_MPEG2_AAC_LOW 128
>> #define FF_PROFILE_MPEG2_AAC_HE 131
>>
>> +#define FF_PROFILE_DNXHD 0
>> +#define FF_PROFILE_DNXHR_LB 1
>> +#define FF_PROFILE_DNXHR_SQ 2
>> +#define FF_PROFILE_DNXHR_HQ 3
>> +#define FF_PROFILE_DNXHR_HQX 4
>> +#define FF_PROFILE_DNXHR_444 5
>> +
>> #define FF_PROFILE_DTS 20
>> #define FF_PROFILE_DTS_ES 30
>> #define FF_PROFILE_DTS_96_24 40
>> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
>> index 9d94b72..e6b8bbc 100644
>> --- a/libavcodec/codec_desc.c
>> +++ b/libavcodec/codec_desc.c
>> @@ -665,6 +665,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
>> .name = "dnxhd",
>> .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"),
>> .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
>> + .profiles = NULL_IF_CONFIG_SMALL(ff_dnxhd_profiles),
>> },
>> {
>> .id = AV_CODEC_ID_THP,
>> diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
>> index 1808080..33dfec2 100644
>> --- a/libavcodec/dnxhddec.c
>> +++ b/libavcodec/dnxhddec.c
>> @@ -33,6 +33,7 @@
>> #include "dnxhddata.h"
>> #include "idctdsp.h"
>> #include "internal.h"
>> +#include "profiles.h"
>> #include "thread.h"
>>
>> typedef struct RowContext {
>> @@ -567,6 +568,23 @@ static int dnxhd_decode_row(AVCodecContext *avctx,
>> void *data,
>> return 0;
>> }
>>
>> +static int dnxhd_get_profile(int cid)
>> +{
>> + switch(cid) {
>> + case 1270:
>> + return FF_PROFILE_DNXHR_444;
>> + case 1271:
>> + return FF_PROFILE_DNXHR_HQX;
>> + case 1272:
>> + return FF_PROFILE_DNXHR_HQ;
>> + case 1273:
>> + return FF_PROFILE_DNXHR_SQ;
>> + case 1274:
>> + return FF_PROFILE_DNXHR_LB;
>> + }
>> + return FF_PROFILE_DNXHD;
>> +}
>> +
>> static int dnxhd_decode_frame(AVCodecContext *avctx, void *data,
>> int *got_frame, AVPacket *avpkt)
>> {
>> @@ -600,6 +618,7 @@ decode_coding_unit:
>> }
>>
>> avctx->pix_fmt = ctx->pix_fmt;
>> + avctx->profile = dnxhd_get_profile(ctx->cid);
>> ret = ff_set_dimensions(avctx, ctx->width, ctx->height);
>> if (ret < 0)
>> return ret;
>> @@ -692,4 +711,5 @@ AVCodec ff_dnxhd_decoder = {
>> .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
>> AV_CODEC_CAP_SLICE_THREADS,
>> .init_thread_copy =
>> ONLY_IF_THREADS_ENABLED(dnxhd_decode_init_thread_copy),
>> + .profiles = NULL_IF_CONFIG_SMALL(ff_dnxhd_profiles),
>> };
>> diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
>> index da745e1..07fb6d6 100644
>> --- a/libavcodec/profiles.c
>> +++ b/libavcodec/profiles.c
>> @@ -46,6 +46,16 @@ const AVProfile ff_dca_profiles[] = {
>> { FF_PROFILE_UNKNOWN },
>> };
>>
>> +const AVProfile ff_dnxhd_profiles[] = {
>> + { FF_PROFILE_DNXHD, "DNXHD"},
>> + { FF_PROFILE_DNXHR_LB, "DNXHR LB"},
>> + { FF_PROFILE_DNXHR_SQ, "DNXHR SQ"},
>> + { FF_PROFILE_DNXHR_HQ, "DNXHR HQ" },
>> + { FF_PROFILE_DNXHR_HQX, "DNXHR HQX"},
>> + { FF_PROFILE_DNXHR_444, "DNXHR 444"},
>> + { FF_PROFILE_UNKNOWN },
>> +};
>> +
>> const AVProfile ff_h264_profiles[] = {
>> { FF_PROFILE_H264_BASELINE, "Baseline" },
>> { FF_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
>> diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
>> index c86c683..eb18b40 100644
>> --- a/libavcodec/profiles.h
>> +++ b/libavcodec/profiles.h
>> @@ -23,6 +23,7 @@
>>
>> extern const AVProfile ff_aac_profiles[];
>> extern const AVProfile ff_dca_profiles[];
>> +extern const AVProfile ff_dnxhd_profiles[];
>> extern const AVProfile ff_h264_profiles[];
>> extern const AVProfile ff_hevc_profiles[];
>> extern const AVProfile ff_jpeg2000_profiles[];
>> --
>> 2.7.3
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
> This looks fine to me.
> Have you checked that you can still retrieve the profile from libavformat
> for the mov muxer?
Yes, the profiles come through mov muxer. but I think I've come up
with something even simpler now, without needing a profile. So I'll
drop this for now and send a new patch.
More information about the ffmpeg-devel
mailing list