forked from FFmpeg/FFmpeg
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edef822
commit 9668284
Showing
8 changed files
with
684 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.