22#include <wels/codec_api.h>
23#include <wels/codec_ver.h>
46 WelsDestroyDecoder(
s->decoder);
64 SDecodingParam param = { 0 };
66 WelsTraceCallback callback_function;
68 if (WelsCreateDecoder(&
s->decoder)) {
74 log_level = WELS_LOG_DETAIL;
76 (*
s->decoder)->SetOption(
s->decoder, DECODER_OPTION_TRACE_LEVEL, &log_level);
77 (*
s->decoder)->SetOption(
s->decoder, DECODER_OPTION_TRACE_CALLBACK, (
void *)&callback_function);
78 (*
s->decoder)->SetOption(
s->decoder, DECODER_OPTION_TRACE_CALLBACK_CONTEXT, (
void *)&avctx);
80#if !OPENH264_VER_AT_LEAST(1, 6)
81 param.eOutputColorFormat = videoFormatI420;
83 param.eEcActiveIdc = ERROR_CON_DISABLE;
84 param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
86 if ((*
s->decoder)->Initialize(
s->decoder, ¶m) != cmResultSuccess) {
101 SBufferInfo info = { 0 };
102 uint8_t *ptrs[4] = {
NULL };
103 int ret, linesize[4];
104 DECODING_STATE
state;
105#if OPENH264_VER_AT_LEAST(1, 7)
119#if OPENH264_VER_AT_LEAST(1, 9)
121 (*
s->decoder)->SetOption(
s->decoder, DECODER_OPTION_END_OF_STREAM, &
end_of_stream);
122 state = (*
s->decoder)->FlushFrame(
s->decoder, ptrs, &info);
127 info.uiInBsTimeStamp = avpkt->
pts;
128#if OPENH264_VER_AT_LEAST(1, 4)
133 state = (*
s->decoder)->DecodeFrameNoDelay(
s->decoder, avpkt->
data, avpkt->
size, ptrs, &info);
135 state = (*
s->decoder)->DecodeFrame2(
s->decoder, avpkt->
data, avpkt->
size, ptrs, &info);
138 if (
state != dsErrorFree) {
142 if (info.iBufferStatus != 1) {
147 ret =
ff_set_dimensions(avctx, info.UsrData.sSystemBuffer.iWidth, info.UsrData.sSystemBuffer.iHeight);
157 linesize[0] = info.UsrData.sSystemBuffer.iStride[0];
158 linesize[1] = linesize[2] = info.UsrData.sSystemBuffer.iStride[1];
163 avframe->
pts = info.uiOutYuvTimeStamp;
165#if OPENH264_VER_AT_LEAST(1, 7)
166 (*
s->decoder)->GetOption(
s->decoder, DECODER_OPTION_PROFILE, &opt);
168 (*
s->decoder)->GetOption(
s->decoder, DECODER_OPTION_LEVEL, &opt);
177 .p.name =
"libopenh264",
189 .bsfs =
"h264_mp4toannexb",
190 .p.wrapper_name =
"libopenh264",
const FFCodec ff_libopenh264_decoder
Libavcodec external API header.
static int FUNC end_of_stream(CodedBitstreamContext *ctx, RWContext *rw, H264RawNALUnitHeader *current)
#define FF_CODEC_CAP_SETS_PKT_DTS
Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
int(* init)(AVBSFContext *ctx)
static struct @346255127015250356166251341105367306144006377143 state
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void av_image_copy2(uint8_t *const dst_data[4], const int dst_linesizes[4], uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const ...
#define AV_NOPTS_VALUE
Undefined timestamp value.
void ff_libopenh264_trace_callback(void *ctx, int level, const char *msg)
static void svc_decode_flush(AVCodecContext *avctx)
static int svc_decode_frame(AVCodecContext *avctx, AVFrame *avframe, int *got_frame, AVPacket *avpkt)
static av_cold int svc_decode_close(AVCodecContext *avctx)
static av_cold int svc_decode_init(AVCodecContext *avctx)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int level
Encoding level descriptor.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...