Skip to content

Commit

Permalink
AMFdec.
Browse files Browse the repository at this point in the history
  • Loading branch information
OvchinnikovDmitrii committed Mar 4, 2020
1 parent edef822 commit 9668284
Show file tree
Hide file tree
Showing 8 changed files with 684 additions and 55 deletions.
4 changes: 2 additions & 2 deletions libavcodec/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ OBJS = ac3_parser.o \
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o
OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.o
OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o
OBJS-$(CONFIG_AMF) += amfenc.o
OBJS-$(CONFIG_AMF) += amfenc.o amfdec.o amf.o
OBJS-$(CONFIG_AUDIO_FRAME_QUEUE) += audio_frame_queue.o
OBJS-$(CONFIG_AUDIODSP) += audiodsp.o
OBJS-$(CONFIG_BLOCKDSP) += blockdsp.o
Expand Down Expand Up @@ -1132,7 +1132,7 @@ SKIPHEADERS += %_tablegen.h \
aacenc_quantization_misc.h \
$(ARCH)/vp56_arith.h \

SKIPHEADERS-$(CONFIG_AMF) += amfenc.h
SKIPHEADERS-$(CONFIG_AMF) += amfenc.h amfdec.h amf.h
SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h
SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h
SKIPHEADERS-$(CONFIG_JNI) += ffjni.h
Expand Down
1 change: 1 addition & 0 deletions libavcodec/allcodecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ extern AVCodec ff_h264_v4l2m2m_decoder;
extern AVCodec ff_h264_mediacodec_decoder;
extern AVCodec ff_h264_mmal_decoder;
extern AVCodec ff_h264_qsv_decoder;
extern AVCodec ff_amf_decoder;
extern AVCodec ff_h264_rkmpp_decoder;
extern AVCodec ff_hap_encoder;
extern AVCodec ff_hap_decoder;
Expand Down
53 changes: 53 additions & 0 deletions libavcodec/amf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "amf.h"

const FormatMap format_map[] =
{
{ AV_PIX_FMT_NV12, AMF_SURFACE_NV12 },

{ AV_PIX_FMT_BGR0, AMF_SURFACE_BGRA },
{ AV_PIX_FMT_BGRA, AMF_SURFACE_BGRA },

{ AV_PIX_FMT_RGB0, AMF_SURFACE_RGBA },
{ AV_PIX_FMT_RGBA, AMF_SURFACE_RGBA },

{ AV_PIX_FMT_0RGB, AMF_SURFACE_ARGB },
{ AV_PIX_FMT_ARGB, AMF_SURFACE_ARGB },

{ AV_PIX_FMT_GRAY8, AMF_SURFACE_GRAY8 },
{ AV_PIX_FMT_YUV420P, AMF_SURFACE_YUV420P },
{ AV_PIX_FMT_YUYV422, AMF_SURFACE_YUY2 },
};

enum AMF_SURFACE_FORMAT amf_av_to_amf_format(enum AVPixelFormat fmt)
{
int i;
for (i = 0; i < amf_countof(format_map); i++) {
if (format_map[i].av_format == fmt) {
return format_map[i].amf_format;
}
}
return AMF_SURFACE_UNKNOWN;
}

enum AVPixelFormat amf_to_av_format(enum AMF_SURFACE_FORMAT fmt)
{
int i;
for (i = 0; i < amf_countof(format_map); i++) {
if (format_map[i].amf_format == fmt) {
return format_map[i].av_format;
}
}
return AMF_SURFACE_UNKNOWN;
}

const enum AVPixelFormat ff_amf_pix_fmts[] = {
AV_PIX_FMT_NV12,
AV_PIX_FMT_YUV420P,
#if CONFIG_D3D11VA
AV_PIX_FMT_D3D11,
#endif
#if CONFIG_DXVA2
AV_PIX_FMT_DXVA2_VLD,
#endif
AV_PIX_FMT_NONE
};
38 changes: 38 additions & 0 deletions libavcodec/amf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef AV_AMF_H
#define AV_AMF_H
#include <AMF/core/Surface.h>
#include "libavformat/avformat.h"

/**
* Error handling helper
*/
#define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
if (!(exp)) { \
av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
return ret_value; \
}

#define AMFAV_GOTO_FAIL_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
if (!(exp)) { \
av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
ret = ret_value; \
goto fail; \
}

#define AMF_TIME_BASE_Q (AVRational){1, AMF_SECOND}

typedef struct FormatMap {
enum AVPixelFormat av_format;
enum AMF_SURFACE_FORMAT amf_format;
} FormatMap;

extern const FormatMap format_map[];
enum AMF_SURFACE_FORMAT amf_av_to_amf_format(enum AVPixelFormat fmt);
enum AVPixelFormat amf_to_av_format(enum AMF_SURFACE_FORMAT fmt);

/**
* Supported formats
*/
extern const enum AVPixelFormat ff_amf_pix_fmts[];

#endif // AV_AMF_H
Loading

0 comments on commit 9668284

Please sign in to comment.