本文整理汇总了C++中AV_WB16函数的典型用法代码示例。如果您正苦于以下问题:C++ AV_WB16函数的具体用法?C++ AV_WB16怎么用?C++ AV_WB16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AV_WB16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rmff_dump_cont
static int rmff_dump_cont(rmff_cont_t *cont, char *buffer, int bufsize) {
int p;
if (!cont) return 0;
if (bufsize < RMFF_CONTHEADER_SIZE + cont->title_len + cont->author_len +
cont->copyright_len + cont->comment_len)
return -1;
AV_WB32(buffer, cont->object_id);
AV_WB32(buffer+4, cont->size);
AV_WB16(buffer+8, cont->object_version);
AV_WB16(buffer+10, cont->title_len);
memcpy(&buffer[12], cont->title, cont->title_len);
p=12+cont->title_len;
AV_WB16(buffer+p, cont->author_len);
memcpy(&buffer[p+2], cont->author, cont->author_len);
p+=2+cont->author_len;
AV_WB16(buffer+p, cont->copyright_len);
memcpy(&buffer[p+2], cont->copyright, cont->copyright_len);
p+=2+cont->copyright_len;
AV_WB16(buffer+p, cont->comment_len);
memcpy(&buffer[p+2], cont->comment, cont->comment_len);
return RMFF_CONTHEADER_SIZE + cont->title_len + cont->author_len +
cont->copyright_len + cont->comment_len;
}
示例2: dnxhd_write_header
static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf)
{
DNXHDEncContext *ctx = avctx->priv_data;
const uint8_t header_prefix[5] = { 0x00,0x00,0x02,0x80,0x01 };
memcpy(buf, header_prefix, 5);
buf[5] = ctx->interlaced ? ctx->cur_field+2 : 0x01;
buf[6] = 0x80; // crc flag off
buf[7] = 0xa0; // reserved
AV_WB16(buf + 0x18, avctx->height); // ALPF
AV_WB16(buf + 0x1a, avctx->width); // SPL
AV_WB16(buf + 0x1d, avctx->height); // NAL
buf[0x21] = 0x38; // FIXME 8 bit per comp
buf[0x22] = 0x88 + (ctx->frame.interlaced_frame<<2);
AV_WB32(buf + 0x28, ctx->cid); // CID
buf[0x2c] = ctx->interlaced ? 0 : 0x80;
buf[0x5f] = 0x01; // UDL
buf[0x167] = 0x02; // reserved
AV_WB16(buf + 0x16a, ctx->m.mb_height * 4 + 4); // MSIPS
buf[0x16d] = ctx->m.mb_height; // Ns
buf[0x16f] = 0x10; // reserved
ctx->msip = buf + 0x170;
return 0;
}
示例3: ff_rtp_send_aac
void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
{
RTPMuxContext *s = s1->priv_data;
AVStream *st = s1->streams[0];
const int max_au_headers_size = 2 + 2 * s->max_frames_per_packet;
int len, max_packet_size = s->max_payload_size - max_au_headers_size;
uint8_t *p;
/* skip ADTS header, if present */
if ((s1->streams[0]->codecpar->extradata_size) == 0) {
size -= 7;
buff += 7;
}
/* test if the packet must be sent */
len = (s->buf_ptr - s->buf);
if (s->num_frames &&
(s->num_frames == s->max_frames_per_packet ||
(len + size) > s->max_payload_size ||
av_compare_ts(s->cur_timestamp - s->timestamp, st->time_base,
s1->max_delay, AV_TIME_BASE_Q) >= 0)) {
int au_size = s->num_frames * 2;
p = s->buf + max_au_headers_size - au_size - 2;
if (p != s->buf) {
memmove(p + 2, s->buf + 2, au_size);
}
/* Write the AU header size */
AV_WB16(p, au_size * 8);
ff_rtp_send_data(s1, p, s->buf_ptr - p, 1);
s->num_frames = 0;
}
if (s->num_frames == 0) {
s->buf_ptr = s->buf + max_au_headers_size;
s->timestamp = s->cur_timestamp;
}
if (size <= max_packet_size) {
p = s->buf + s->num_frames++ * 2 + 2;
AV_WB16(p, size * 8);
memcpy(s->buf_ptr, buff, size);
s->buf_ptr += size;
} else {
int au_size = size;
max_packet_size = s->max_payload_size - 4;
p = s->buf;
AV_WB16(p, 2 * 8);
while (size > 0) {
len = FFMIN(size, max_packet_size);
AV_WB16(&p[2], au_size * 8);
memcpy(p + 4, buff, len);
ff_rtp_send_data(s1, p, len + 4, len == size);
size -= len;
buff += len;
}
}
}
示例4: mp3_update_xing
static void mp3_update_xing(AVFormatContext *s)
{
MP3Context *mp3 = s->priv_data;
AVReplayGain *rg;
uint16_t tag_crc;
uint8_t *toc;
int i, rg_size;
/* replace "Xing" identification string with "Info" for CBR files. */
if (!mp3->has_variable_bitrate)
AV_WL32(mp3->xing_frame + mp3->xing_offset, MKTAG('I', 'n', 'f', 'o'));
AV_WB32(mp3->xing_frame + mp3->xing_offset + 8, mp3->frames);
AV_WB32(mp3->xing_frame + mp3->xing_offset + 12, mp3->size);
toc = mp3->xing_frame + mp3->xing_offset + 16;
toc[0] = 0; // first toc entry has to be zero.
for (i = 1; i < XING_TOC_SIZE; ++i) {
int j = i * mp3->pos / XING_TOC_SIZE;
int seek_point = 256LL * mp3->bag[j] / mp3->size;
toc[i] = FFMIN(seek_point, 255);
}
/* write replaygain */
rg = (AVReplayGain*)av_stream_get_side_data(s->streams[0], AV_PKT_DATA_REPLAYGAIN,
&rg_size);
if (rg && rg_size >= sizeof(*rg)) {
uint16_t val;
AV_WB32(mp3->xing_frame + mp3->xing_offset + 131,
av_rescale(rg->track_peak, 1 << 23, 100000));
if (rg->track_gain != INT32_MIN) {
val = FFABS(rg->track_gain / 10000) & ((1 << 9) - 1);
val |= (rg->track_gain < 0) << 9;
val |= 1 << 13;
AV_WB16(mp3->xing_frame + mp3->xing_offset + 135, val);
}
if (rg->album_gain != INT32_MIN) {
val = FFABS(rg->album_gain / 10000) & ((1 << 9) - 1);
val |= (rg->album_gain < 0) << 9;
val |= 1 << 14;
AV_WB16(mp3->xing_frame + mp3->xing_offset + 137, val);
}
}
AV_WB32(mp3->xing_frame + mp3->xing_offset + XING_SIZE - 8, mp3->audio_size);
AV_WB16(mp3->xing_frame + mp3->xing_offset + XING_SIZE - 4, mp3->audio_crc);
tag_crc = av_crc(av_crc_get_table(AV_CRC_16_ANSI_LE), 0, mp3->xing_frame, 190);
AV_WB16(mp3->xing_frame + mp3->xing_offset + XING_SIZE - 2, tag_crc);
avio_seek(s->pb, mp3->xing_frame_offset, SEEK_SET);
avio_write(s->pb, mp3->xing_frame, mp3->xing_frame_size);
avio_seek(s->pb, 0, SEEK_END);
}
示例5: qdm2_restore_block
/**
* Adds a superblock header around a set of subpackets.
*
* @return <0 on error, else 0.
*/
static int qdm2_restore_block(PayloadContext *qdm, AVStream *st, AVPacket *pkt)
{
int to_copy, n, res, include_csum;
uint8_t *p, *csum_pos = NULL;
/* create packet to hold subpkts into a superblock */
assert(qdm->cache > 0);
for (n = 0; n < 0x80; n++)
if (qdm->len[n] > 0)
break;
assert(n < 0x80);
if ((res = av_new_packet(pkt, qdm->block_size)) < 0)
return res;
memset(pkt->data, 0, pkt->size);
pkt->stream_index = st->index;
p = pkt->data;
/* superblock header */
if (qdm->len[n] > 0xff) {
*p++ = qdm->block_type | 0x80;
AV_WB16(p, qdm->len[n]);
p += 2;
} else {
*p++ = qdm->block_type;
*p++ = qdm->len[n];
}
if ((include_csum = (qdm->block_type == 2 || qdm->block_type == 4))) {
csum_pos = p;
p += 2;
}
/* subpacket data */
to_copy = FFMIN(qdm->len[n], pkt->size - (p - pkt->data));
memcpy(p, qdm->buf[n], to_copy);
qdm->len[n] = 0;
/* checksum header */
if (include_csum) {
unsigned int total = 0;
uint8_t *q;
for (q = pkt->data; q < &pkt->data[qdm->block_size]; q++)
total += *q;
AV_WB16(csum_pos, (uint16_t) total);
}
return 0;
}
示例6: get_theora_extradata
static void get_theora_extradata(AVCodecContext *ctx,
GstStructure *in_struc)
{
const GValue *array;
const GValue *value;
GstBuffer *buf;
size_t size = 0;
uint8_t *p;
array = gst_structure_get_value(in_struc, "streamheader");
if (!array)
return;
/* get size */
for (unsigned i = 0; i < gst_value_array_get_size(array); i++) {
value = gst_value_array_get_value(array, i);
buf = gst_value_get_buffer(value);
size += buf->size + 2;
}
/* fill it up */
ctx->extradata = p = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
for (unsigned i = 0; i < gst_value_array_get_size(array); i++) {
value = gst_value_array_get_value(array, i);
buf = gst_value_get_buffer(value);
AV_WB16(p, buf->size);
p += 2;
memcpy(p, buf->data, buf->size);
p += buf->size;
}
ctx->extradata_size = p - ctx->extradata;
}
示例7: tcp_write_packet
static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st)
{
RTSPState *rt = s->priv_data;
AVFormatContext *rtpctx = rtsp_st->transport_priv;
uint8_t *buf, *ptr;
int size;
uint8_t interleave_header[4];
size = url_close_dyn_buf(rtpctx->pb, &buf);
ptr = buf;
while (size > 4) {
uint32_t packet_len = AV_RB32(ptr);
int id;
ptr += 4;
size -= 4;
if (packet_len > size || packet_len < 2)
break;
if (ptr[1] >= 200 && ptr[1] <= 204)
id = rtsp_st->interleaved_max; /* RTCP */
else
id = rtsp_st->interleaved_min; /* RTP */
interleave_header[0] = '$';
interleave_header[1] = id;
AV_WB16(interleave_header + 2, packet_len);
url_write(rt->rtsp_hd, interleave_header, 4);
url_write(rt->rtsp_hd, ptr, packet_len);
ptr += packet_len;
size -= packet_len;
}
av_free(buf);
url_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE);
return 0;
}
示例8: concatenate_packet
/** Concatenate an ogg_packet into the extradata. */
static int concatenate_packet(unsigned int* offset,
AVCodecContext* avc_context,
const ogg_packet* packet)
{
const char* message = NULL;
int newsize = avc_context->extradata_size + 2 + packet->bytes;
int err = AVERROR_INVALIDDATA;
if (packet->bytes < 0) {
message = "ogg_packet has negative size";
} else if (packet->bytes > 0xffff) {
message = "ogg_packet is larger than 65535 bytes";
} else if (newsize < avc_context->extradata_size) {
message = "extradata_size would overflow";
} else {
if ((err = av_reallocp(&avc_context->extradata, newsize)) < 0) {
avc_context->extradata_size = 0;
message = "av_realloc failed";
}
}
if (message) {
av_log(avc_context, AV_LOG_ERROR, "concatenate_packet failed: %s\n", message);
return err;
}
avc_context->extradata_size = newsize;
AV_WB16(avc_context->extradata + (*offset), packet->bytes);
*offset += 2;
memcpy(avc_context->extradata + (*offset), packet->packet, packet->bytes);
(*offset) += packet->bytes;
return 0;
}
示例9: adx_encode
static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
ADXChannelState *prev, int channels)
{
PutBitContext pb;
int scale;
int i, j;
int s0, s1, s2, d;
int max = 0;
int min = 0;
s1 = prev->s1;
s2 = prev->s2;
for (i = 0, j = 0; j < 32; i += channels, j++) {
s0 = wav[i];
d = ((s0 << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
if (max < d)
max = d;
if (min > d)
min = d;
s2 = s1;
s1 = s0;
}
if (max == 0 && min == 0) {
prev->s1 = s1;
prev->s2 = s2;
memset(adx, 0, BLOCK_SIZE);
return;
}
if (max / 7 > -min / 8)
scale = max / 7;
else
scale = -min / 8;
if (scale == 0)
scale = 1;
AV_WB16(adx, scale);
init_put_bits(&pb, adx + 2, 16);
s1 = prev->s1;
s2 = prev->s2;
for (i = 0, j = 0; j < 32; i += channels, j++) {
d = ((wav[i] << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
d = av_clip(ROUNDED_DIV(d, scale), -8, 7);
put_sbits(&pb, 4, d);
s0 = ((d << COEFF_BITS) * scale + c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS;
s2 = s1;
s1 = s0;
}
prev->s1 = s1;
prev->s2 = s2;
flush_put_bits(&pb);
}
示例10: avpriv_dca_convert_bitstream
int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
int max_size)
{
uint32_t mrk;
int i, tmp;
PutBitContext pb;
if ((unsigned) src_size > (unsigned) max_size)
src_size = max_size;
mrk = AV_RB32(src);
switch (mrk) {
case DCA_SYNCWORD_CORE_BE:
memcpy(dst, src, src_size);
return src_size;
case DCA_SYNCWORD_CORE_LE:
for (i = 0; i < (src_size + 1) >> 1; i++) {
AV_WB16(dst, AV_RL16(src));
src += 2;
dst += 2;
}
return src_size;
case DCA_SYNCWORD_CORE_14B_BE:
case DCA_SYNCWORD_CORE_14B_LE:
init_put_bits(&pb, dst, max_size);
for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
tmp = ((mrk == DCA_SYNCWORD_CORE_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
put_bits(&pb, 14, tmp);
}
flush_put_bits(&pb);
return (put_bits_count(&pb) + 7) >> 3;
default:
return AVERROR_INVALIDDATA;
}
}
示例11: sctp_wait_fd
static int sctp_wait_fd(int fd, int write)
{
int ev = write ? POLLOUT : POLLIN;
struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
int ret;
ret = poll(&p, 1, 100);
return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);
}
static int sctp_read(URLContext *h, uint8_t *buf, int size)
{
SCTPContext *s = h->priv_data;
int ret;
if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
ret = sctp_wait_fd(s->fd, 0);
if (ret < 0)
return ret;
}
if (s->max_streams) {
/*StreamId is introduced as a 2byte code into the stream*/
struct sctp_sndrcvinfo info = { 0 };
ret = ff_sctp_recvmsg(s->fd, buf + 2, size - 2, NULL, 0, &info, 0);
AV_WB16(buf, info.sinfo_stream);
ret = ret < 0 ? ret : ret + 2;
} else
ret = recv(s->fd, buf, size, 0);
return ret < 0 ? ff_neterrno() : ret;
}
示例12: jpeg_table_header
static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
ScanTable *intra_scantable,
uint16_t luma_intra_matrix[64],
uint16_t chroma_intra_matrix[64],
int hsample[3])
{
int i, j, size;
uint8_t *ptr;
MpegEncContext *s = avctx->priv_data;
if (avctx->codec_id != AV_CODEC_ID_LJPEG) {
int matrix_count = 1 + !!memcmp(luma_intra_matrix,
chroma_intra_matrix,
sizeof(luma_intra_matrix[0]) * 64);
if (s->force_duplicated_matrix)
matrix_count = 2;
/* quant matrixes */
put_marker(p, DQT);
put_bits(p, 16, 2 + matrix_count * (1 + 64));
put_bits(p, 4, 0); /* 8 bit precision */
put_bits(p, 4, 0); /* table 0 */
for(i=0;i<64;i++) {
j = intra_scantable->permutated[i];
put_bits(p, 8, luma_intra_matrix[j]);
}
if (matrix_count > 1) {
put_bits(p, 4, 0); /* 8 bit precision */
put_bits(p, 4, 1); /* table 1 */
for(i=0;i<64;i++) {
j = intra_scantable->permutated[i];
put_bits(p, 8, chroma_intra_matrix[j]);
}
}
}
if(avctx->active_thread_type & FF_THREAD_SLICE){
put_marker(p, DRI);
put_bits(p, 16, 4);
put_bits(p, 16, (avctx->width-1)/(8*hsample[0]) + 1);
}
/* huffman table */
put_marker(p, DHT);
flush_put_bits(p);
ptr = put_bits_ptr(p);
put_bits(p, 16, 0); /* patched later */
size = 2;
size += put_huffman_table(p, 0, 0, avpriv_mjpeg_bits_dc_luminance,
avpriv_mjpeg_val_dc);
size += put_huffman_table(p, 0, 1, avpriv_mjpeg_bits_dc_chrominance,
avpriv_mjpeg_val_dc);
size += put_huffman_table(p, 1, 0, avpriv_mjpeg_bits_ac_luminance,
avpriv_mjpeg_val_ac_luminance);
size += put_huffman_table(p, 1, 1, avpriv_mjpeg_bits_ac_chrominance,
avpriv_mjpeg_val_ac_chrominance);
AV_WB16(ptr, size);
}
示例13: jpeg_put_comments
static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
{
int size;
uint8_t *ptr;
if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) {
/* JFIF header */
put_marker(p, APP0);
put_bits(p, 16, 16);
avpriv_put_string(p, "JFIF", 1); /* this puts the trailing zero-byte too */
/* The most significant byte is used for major revisions, the least
* significant byte for minor revisions. Version 1.02 is the current
* released revision. */
put_bits(p, 16, 0x0102);
put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
put_bits(p, 16, avctx->sample_aspect_ratio.num);
put_bits(p, 16, avctx->sample_aspect_ratio.den);
put_bits(p, 8, 0); /* thumbnail width */
put_bits(p, 8, 0); /* thumbnail height */
}
/* comment */
if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) {
put_marker(p, COM);
flush_put_bits(p);
ptr = put_bits_ptr(p);
put_bits(p, 16, 0); /* patched later */
avpriv_put_string(p, LIBAVCODEC_IDENT, 1);
size = strlen(LIBAVCODEC_IDENT)+3;
AV_WB16(ptr, size);
}
if (((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
avctx->pix_fmt == AV_PIX_FMT_YUV444P) && avctx->color_range != AVCOL_RANGE_JPEG)
|| avctx->color_range == AVCOL_RANGE_MPEG) {
put_marker(p, COM);
flush_put_bits(p);
ptr = put_bits_ptr(p);
put_bits(p, 16, 0); /* patched later */
avpriv_put_string(p, "CS=ITU601", 1);
size = strlen("CS=ITU601")+3;
AV_WB16(ptr, size);
}
}
示例14: text2movsub
static int text2movsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size, int keyframe){
if (buf_size > 0xffff) return 0;
*poutbuf_size = buf_size + 2;
*poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE);
AV_WB16(*poutbuf, buf_size);
memcpy(*poutbuf + 2, buf, buf_size);
return 1;
}
示例15: jpeg_put_comments
static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
{
int size;
uint8_t *ptr;
if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) {
/* JFIF header */
put_marker(p, APP0);
put_bits(p, 16, 16);
avpriv_put_string(p, "JFIF", 1); /* this puts the trailing zero-byte too */
put_bits(p, 16, 0x0102); /* v 1.02 */
put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
put_bits(p, 16, avctx->sample_aspect_ratio.num);
put_bits(p, 16, avctx->sample_aspect_ratio.den);
put_bits(p, 8, 0); /* thumbnail width */
put_bits(p, 8, 0); /* thumbnail height */
}
/* comment */
if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
put_marker(p, COM);
flush_put_bits(p);
ptr = put_bits_ptr(p);
put_bits(p, 16, 0); /* patched later */
avpriv_put_string(p, LIBAVCODEC_IDENT, 1);
size = strlen(LIBAVCODEC_IDENT)+3;
AV_WB16(ptr, size);
}
if (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
avctx->pix_fmt == AV_PIX_FMT_YUV444P) {
put_marker(p, COM);
flush_put_bits(p);
ptr = put_bits_ptr(p);
put_bits(p, 16, 0); /* patched later */
avpriv_put_string(p, "CS=ITU601", 1);
size = strlen("CS=ITU601")+3;
AV_WB16(ptr, size);
}
}