adtsenc.c File Reference

#include "libavcodec/bitstream.h"
#include "avformat.h"

Go to the source code of this file.

Data Structures

struct  ADTSContext

Defines

#define ADTS_HEADER_SIZE   7

Functions

static int decode_extradata (ADTSContext *adts, uint8_t *buf, int size)
static int adts_write_header (AVFormatContext *s)
static int adts_write_frame_header (AVFormatContext *s, int size)
static int adts_write_packet (AVFormatContext *s, AVPacket *pkt)

Variables

AVOutputFormat adts_muxer


Define Documentation

#define ADTS_HEADER_SIZE   7

Definition at line 26 of file adtsenc.c.

Referenced by adts_write_frame_header().


Function Documentation

static int adts_write_frame_header ( AVFormatContext s,
int  size 
) [static]

Definition at line 60 of file adtsenc.c.

References ADTS_HEADER_SIZE, ADTSContext::channel_conf, flush_put_bits(), init_put_bits(), ADTSContext::objecttype, AVFormatContext::pb, AVFormatContext::priv_data, put_bits(), put_buffer(), and ADTSContext::sample_rate_index.

Referenced by adts_write_packet().

00061 {
00062     ADTSContext *ctx = s->priv_data;
00063     PutBitContext pb;
00064     uint8_t buf[ADTS_HEADER_SIZE];
00065 
00066     init_put_bits(&pb, buf, ADTS_HEADER_SIZE);
00067 
00068     /* adts_fixed_header */
00069     put_bits(&pb, 12, 0xfff);   /* syncword */
00070     put_bits(&pb, 1, 0);        /* ID */
00071     put_bits(&pb, 2, 0);        /* layer */
00072     put_bits(&pb, 1, 1);        /* protection_absent */
00073     put_bits(&pb, 2, ctx->objecttype); /* profile_objecttype */
00074     put_bits(&pb, 4, ctx->sample_rate_index);
00075     put_bits(&pb, 1, 0);        /* private_bit */
00076     put_bits(&pb, 3, ctx->channel_conf); /* channel_configuration */
00077     put_bits(&pb, 1, 0);        /* original_copy */
00078     put_bits(&pb, 1, 0);        /* home */
00079 
00080     /* adts_variable_header */
00081     put_bits(&pb, 1, 0);        /* copyright_identification_bit */
00082     put_bits(&pb, 1, 0);        /* copyright_identification_start */
00083     put_bits(&pb, 13, ADTS_HEADER_SIZE + size); /* aac_frame_length */
00084     put_bits(&pb, 11, 0x7ff);   /* adts_buffer_fullness */
00085     put_bits(&pb, 2, 0);        /* number_of_raw_data_blocks_in_frame */
00086 
00087     flush_put_bits(&pb);
00088     put_buffer(s->pb, buf, ADTS_HEADER_SIZE);
00089 
00090     return 0;
00091 }

static int adts_write_header ( AVFormatContext s  )  [static]

Definition at line 49 of file adtsenc.c.

References AVStream::codec, decode_extradata(), AVCodecContext::extradata, AVCodecContext::extradata_size, AVFormatContext::priv_data, and AVFormatContext::streams.

00050 {
00051     ADTSContext *adts = s->priv_data;
00052     AVCodecContext *avc = s->streams[0]->codec;
00053 
00054     if(avc->extradata_size > 0)
00055         decode_extradata(adts, avc->extradata, avc->extradata_size);
00056 
00057     return 0;
00058 }

static int adts_write_packet ( AVFormatContext s,
AVPacket pkt 
) [static]

Definition at line 93 of file adtsenc.c.

References adts_write_frame_header(), AVPacket::data, AVFormatContext::pb, AVFormatContext::priv_data, put_buffer(), put_flush_packet(), AVPacket::size, and ADTSContext::write_adts.

00094 {
00095     ADTSContext *adts = s->priv_data;
00096     ByteIOContext *pb = s->pb;
00097 
00098     if (!pkt->size)
00099         return 0;
00100     if(adts->write_adts)
00101         adts_write_frame_header(s, pkt->size);
00102     put_buffer(pb, pkt->data, pkt->size);
00103     put_flush_packet(pb);
00104 
00105     return 0;
00106 }

static int decode_extradata ( ADTSContext adts,
uint8_t *  buf,
int  size 
) [static]

Definition at line 35 of file adtsenc.c.

References ADTSContext::channel_conf, get_bits(), init_get_bits(), ADTSContext::objecttype, ADTSContext::sample_rate_index, and ADTSContext::write_adts.

Referenced by adts_write_header().

00036 {
00037     GetBitContext gb;
00038 
00039     init_get_bits(&gb, buf, size * 8);
00040     adts->objecttype = get_bits(&gb, 5) - 1;
00041     adts->sample_rate_index = get_bits(&gb, 4);
00042     adts->channel_conf = get_bits(&gb, 4);
00043 
00044     adts->write_adts = 1;
00045 
00046     return 0;
00047 }


Variable Documentation

AVOutputFormat adts_muxer

Initial value:

 {
    "adts",
    NULL_IF_CONFIG_SMALL("ADTS AAC"),
    "audio/aac",
    "aac",
    sizeof(ADTSContext),
    CODEC_ID_AAC,
    CODEC_ID_NONE,
    adts_write_header,
    adts_write_packet,
}

Definition at line 108 of file adtsenc.c.


Generated on Sat Oct 11 19:45:03 2008 for libextractor by  doxygen 1.5.1