45 0xff, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78,
75 0, (
const void **)&
pix_fmts, &num_pix_fmts);
105 for (
int i = 0;
i < n_frames;
i++) {
112 memset(
frame->data[1], 64, (
size_t)
frame->linesize[1] * chroma_h);
114 memset(
frame->data[2], 64, (
size_t)
frame->linesize[2] * chroma_h);
133 memcpy(buf + buf_size,
pkt->data,
pkt->size);
134 buf_size +=
pkt->size;
155 memcpy(buf + buf_size,
pkt->data,
pkt->size);
156 buf_size +=
pkt->size;
186 for (k = 0; k < n; k++)
204 const uint8_t *buf,
int buf_size)
228 const uint8_t *buf,
int buf_size,
int chunk_size,
229 uint8_t **all_out,
size_t *all_size)
232 const uint8_t *p = buf;
233 int remaining = buf_size;
242 chunk_size = buf_size ? buf_size : 1;
244 while (remaining > 0) {
245 int feed = remaining < chunk_size ? remaining : chunk_size;
255 snprintf(label,
sizeof(label),
"%s[%d]",
tag, n++);
270 p += consumed > 0 ? consumed :
feed;
271 remaining -= consumed > 0 ? consumed :
feed;
284 snprintf(label,
sizeof(label),
"%s[%d]",
tag, n++);
304 const char *codec_name = argc > 1 ? argv[1] :
"h261";
305 int width = argc > 2 ? atoi(argv[2]) : 176;
306 int height = argc > 3 ? atoi(argv[3]) : 144;
309 uint8_t *encoded =
NULL;
313 uint8_t *bulk_data =
NULL, *split_data =
NULL;
314 size_t bulk_sz = 0, split_sz = 0;
341 if (!encoded || encoded_size == 0) {
357 &bulk_data, &bulk_sz);
366 (
int)encoded_size / 2, &split_data, &split_sz);
372 if (bulk_sz != split_sz || memcmp(bulk_data, split_data, bulk_sz) != 0) {
static void feed(AVFilterContext *ctx, int ch, const float *in_samples, float *out_samples, float *in_frame, float *out_dist_frame, float *windowed_frame, float *drc_frame, float *spectrum_buf, float *energy, float *target_gain, float *envelope, float *factors)
static int parse_once(AVCodecContext *avctx, enum AVCodecID codec_id, const char *label, const uint8_t *buf, int buf_size)
static uint8_t * encode_frames(const AVCodec *enc, int width, int height, int n_frames, size_t *out_size)
static const uint8_t garbage[]
static void print_parse_result(const char *label, const uint8_t *out, int out_size)
static int parse_stream(AVCodecContext *avctx, enum AVCodecID codec_id, const char *tag, const uint8_t *buf, int buf_size, int chunk_size, uint8_t **all_out, size_t *all_size)
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define AV_CEIL_RSHIFT(a, b)
__device__ int printf(const char *,...)
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
AVCodecID
Identify the syntax and semantics of the bitstream.
const AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
int avcodec_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out, int *out_num)
Retrieve a list of all supported values for a given configuration type.
@ AV_CODEC_CONFIG_PIX_FORMAT
AVPixelFormat, terminated by AV_PIX_FMT_NONE.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
AVCodecParserContext * av_parser_init(enum AVCodecID codec_id)
void av_parser_close(AVCodecParserContext *s)
int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts, int64_t pos)
Parse a packet.
#define AVERROR_EOF
End of file.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_log_set_level(int level)
Set the log level.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVPixelFormat
Pixel format.
@ 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.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).