110static struct bitbuf bitbuf_init(const uint8_t *base, 
int bitsize, 
int start_ofs)
 
  119static int bitbuf_left(
struct bitbuf *
b)
 
  121    return b->bitsize - 
b->ofs;
 
  124static uint32_t getbits(
struct bitbuf *
b, 
int n)
 
  134    if (n + 
b->ofs > 
b->bitsize) {
 
  136        n = 
b->bitsize - 
b->ofs;
 
  138    ofs = 7 - 
b->ofs % 8;   
 
  140    d = 
b->base + 
b->ofs / 8;   
 
  141    for (i=0 ; i < n; i++) {
 
  142        retval += retval + (*
d & mask ? 1 : 0); 
 
  153static void check_h261(
struct fbuf_t *
b)
 
  155    struct bitbuf 
a = bitbuf_init(
b->data, 
b->used * 8, 0);
 
  172        (y & 0x4) ? 
"" : 
"Q",
 
  174    while ( (x = getbits(&
a, 1)) == 1)
 
  177    while ( (x = bitbuf_left(&
a)) > 0) {
 
  190        while ( (x = getbits(&
a, 1)) == 1)
 
  192        while ( (x = bitbuf_left(&
a)) > 0) { 
 
  198void dump_buf(
struct fbuf_t *
b);
 
  201    int i, x, last2lines;
 
  204    last2lines = (
b->used - 16) & ~0xf;
 
  206    for (i = 0; i < 
b->used; i++) {
 
  211            memset(
buf, 
'\0', 
sizeof(
buf));
 
  212            sprintf(
buf, 
"%04x: ", (
unsigned)i);
 
  214        sprintf(
buf + 6 + x*3, 
"%02hhx ", 
b->data[i]);
 
  215        if (i > 31 && i < last2lines)
 
  229                   int format, 
int head, 
struct ast_frame *prev)
 
 
  280    int need = 
len + FF_INPUT_BUFFER_PADDING_SIZE;
 
  284    if (
b->data == 
NULL) {
 
  289    } 
else if (
b->used + need > 
b->size) {
 
  290        b->size = 
b->used + need;
 
  293    if (
b->data == 
NULL) {
 
  298    if (
b->used == 0 && 
b->ebit != 0) {
 
  302    dst = 
b->data + 
b->used;
 
  307        mask = (1 << 
b->ebit) - 1;
 
  310        dst[-1] |= (*
src & mask);   
 
  315            b->ebit, sbit, 
b->used);
 
  321    b->data[
b->used] = 0;   
 
 
  346    enc_ctx->flags |=CODEC_FLAG_H263P_UMV; 
 
  347    enc_ctx->flags |=CODEC_FLAG_AC_PRED; 
 
  348    enc_ctx->flags |=CODEC_FLAG_H263P_SLICE_STRUCT; 
 
  349    enc_ctx->flags |= CODEC_FLAG_H263P_AIC; 
 
 
  364    uint8_t *
d = 
b->data;
 
  368    for (;
len > 0; 
len -= l, 
d += l) {
 
  373        if (
len >= 3 && 
d[0] == 0 && 
d[1] == 0 && 
d[2] >= 0x80) {
 
  375            for (i = 3; i < 
len - 3; i++) {
 
  376                if (
d[i] == 0 && 
d[i+1] == 0 && 
d[i+2] >= 0x80) {
 
  382        if (l > mtu || l > 
len) { 
 
  385        if (l < 1 || l > mtu) {
 
  390        if (
d[0] == 0 && 
d[1] == 0) { 
 
 
  441    PLEN = ( (
data[0] & 1) << 5 ) | ( (
data[1] & 0xf8) >> 3);
 
 
  463    struct fbuf_t *
b = &v->enc_out;
 
  466    b->used = avcodec_encode_video(v->enc_ctx, 
b->data, 
b->size, v->enc_in_frame);
 
  467    i = avcodec_encode_video(v->enc_ctx, 
b->data + 
b->used, 
b->size - 
b->used, 
NULL); 
 
 
  484    uint8_t *src = 
b->data;
 
  485    int srclen = 
b->used;
 
  511        memmove(
b->data, src, srclen);
 
 
  519    .format = AST_FORMAT_H263_PLUS,
 
 
  533    enc_ctx->
flags |= CODEC_FLAG_H263P_UMV;
 
  534    enc_ctx->flags |= CODEC_FLAG_H263P_AIC;
 
  535    enc_ctx->flags |= CODEC_FLAG_H263P_SLICE_STRUCT;
 
  536    enc_ctx->flags |= CODEC_FLAG_AC_PRED;
 
 
  578    uint8_t *
d = 
b->data;
 
  579    int start = 0, i, 
len = 
b->used;
 
  581    const int pheader_len = 4;  
 
  582    uint8_t h263_hdr[12];   
 
  583    uint8_t *h = h263_hdr;  
 
  585#define H263_MIN_LEN    6 
  589    memset(h263_hdr, 
'\0', 
sizeof(h263_hdr));
 
  602    h[1] = ( (
d[4] & 0x1f) << 3 ) | 
 
  603        ( (
d[5] & 0xc0) >> 5 );     
 
  611        for (; i < 
len ; i++) {
 
  612            uint8_t x, rpos, lpos;
 
  626            for (rpos = 0x80, rpos_i = 8; rpos; rpos >>= 1, rpos_i--)
 
  630            for (lpos = rpos; lpos ; lpos >>= 1)
 
 
  678    if ( (
data[0] & 0x80) == 0) {
 
 
  708    enc_ctx->rtp_payload_size = 0; 
 
 
  732    uint8_t *
d = 
b->data;
 
  733    int start = 0, i, 
len = 
b->used;
 
  735    const int pheader_len = 4;
 
  737    uint8_t *h = h261_hdr;  
 
  738    int sbit = 0, ebit = 0;
 
  740#define H261_MIN_LEN 10 
  744    memset(h261_hdr, 
'\0', 
sizeof(h261_hdr));
 
  751    for (i = 
H261_MIN_LEN, start = 0; start < 
len - 1; start = i, i += 4) {
 
  755        int found = 0, found_ebit = 0;  
 
  756        for (; i < 
len ; i++) {
 
  757            uint8_t x, rpos, lpos;
 
  768            for (rpos = 0x80, ebit = 7; rpos; ebit--, rpos >>= 1)
 
  772            for (lpos = (rpos >> 1); lpos ; lpos >>= 1)
 
  790        if (i - start > mtu && found) {
 
  807        h[0] = ( (sbit & 7) << 5 ) | ( (ebit & 7) << 2 ) | 1;
 
  811        sbit = (8 - ebit) & 7;
 
 
  835    sbit = (
data[0] >> 5) & 7;
 
  836    ebit = (
data[0] >> 2) & 7;
 
 
  858    enc_ctx->
flags |= CODEC_FLAG_AC_PRED;
 
  859    enc_ctx->flags |= CODEC_FLAG_H263P_UMV;
 
  860    enc_ctx->flags |= CODEC_FLAG_QPEL;
 
  861    enc_ctx->flags |= CODEC_FLAG_4MV;
 
  862    enc_ctx->flags |= CODEC_FLAG_GMC;
 
  863    enc_ctx->flags |= CODEC_FLAG_LOOP_FILTER;
 
  864    enc_ctx->flags |= CODEC_FLAG_H263P_SLICE_STRUCT;
 
  866    enc_ctx->rtp_payload_size = 0; 
 
 
  875    uint8_t *
d = 
b->data;
 
  876    uint8_t *
end = 
d + 
b->used;
 
 
  900    int full_frame = 0, 
datalen = 
b->used;
 
  901    int ret = avcodec_decode_video(v->
dec_ctx, v->
d_frame, &full_frame,
 
  909        memmove(
b->data, 
b->data + ret, 
datalen);
 
 
  917    .format = AST_FORMAT_MP4_VIDEO,
 
 
  928    enc_ctx->
flags |= CODEC_FLAG_TRUNCATED;
 
  932    enc_ctx->rtp_mode = 0;
 
  933    enc_ctx->rtp_payload_size = 0;
 
  934    enc_ctx->bit_rate_tolerance = enc_ctx->bit_rate;
 
 
  940    dec_ctx->flags |= CODEC_FLAG_TRUNCATED;
 
 
  963    uint8_t *
d, *start = 
b->data;
 
  964    uint8_t *
end = start + 
b->used;
 
  969#define HAVE_NAL(x) (x[-4] == 0 && x[-3] == 0 && x[-2] == 0 && x[-1] == 1) 
  970    for (start += 4; start < 
end; start++) {
 
  971        int ty = start[0] & 0x1f;
 
  972        if (
HAVE_NAL(start) && ty != 0 && ty != 31)
 
  980   for (;start < 
end - 4; start = 
d) {
 
  986    for (
d = start + 4; 
d < 
end; 
d++) {
 
  994    } 
else if (ty == 0 || ty == 31) { 
 
  996            ty, 
d - (uint8_t *)
b->data, 
b->used);
 
 1000    size = 
d - start - 4;   
 
 1015    hdr[0] = (*start & 0xe0) | 28;  
 
 1016    hdr[1] = (*start++ & 0x1f) | 0x80 ; 
 
 1020        int frag_size = 
MIN(size, mtu);
 
 1030        data[1] = hdr[1] | (size == 0 ? 0x40 : 0);  
 
 
 1049    uint8_t scp[] = { 0x00, 0x00, 0x00, 0x01 };
 
 1058    if (
data[0] & 0x80) {
 
 1078        if (
data[1] & 0x80) { 
 
 
 1121        { AST_FORMAT_H263_PLUS, CODEC_ID_H263,  
CM_RD }, 
 
 1122        { AST_FORMAT_H263_PLUS, CODEC_ID_H263P, 
CM_WR },
 
 1127        { AST_FORMAT_MP4_VIDEO, CODEC_ID_MPEG4, 
CM_RDWR },
 
 
 1141    return CODEC_ID_NONE;
 
 
 1179        av_parser_close(v->
parser);
 
 
 1229    v->
dec_ctx = avcodec_alloc_context();
 
 1248    v->
d_frame = avcodec_alloc_frame();
 
 
struct sla_ringing_trunk * first
Asterisk main include file. File version handling, generic pbx functions.
#define ast_realloc(p, len)
A wrapper for realloc()
#define ast_calloc(num, len)
A wrapper for calloc()
void fbuf_free(struct fbuf_t *)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Asterisk internal frame definitions.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
union ast_frame::@239 data
decoder_decap_f dec_decap
encoder_encap_f enc_encap
struct fbuf_t * dec_in_cur
AVCodecParserContext * parser
struct video_codec_desc * d_callbacks
struct fbuf_t * dec_in_dpy
struct fbuf_t dec_in[N_DEC_IN]
int(* decoder_decap_f)(struct fbuf_t *b, uint8_t *data, int len)
extract the bitstream from RTP frames and store in the fbuf. return 0 if ok, 1 on error
static struct video_codec_desc h263p_codec
static int h263_decap(struct fbuf_t *b, uint8_t *data, int len)
static int h264_enc_init(AVCodecContext *enc_ctx)
static int ffmpeg_decode(struct video_dec_desc *v, struct fbuf_t *b)
static int h263_enc_init(AVCodecContext *enc_ctx)
static int h261_decap(struct fbuf_t *b, uint8_t *data, int len)
static int ffmpeg_encode(struct video_out_desc *v)
static struct ast_frame * mpeg4_encap(struct fbuf_t *b, int mtu, struct ast_frame **tail)
static const struct _cm video_formats[]
static int h263p_enc_init(AVCodecContext *enc_ctx)
initialization of h263p
static int mpeg4_decode(struct video_dec_desc *v, struct fbuf_t *b)
static struct ast_frame * h263_encap(struct fbuf_t *b, int mtu, struct ast_frame **tail)
static struct video_codec_desc h264_codec
static struct ast_frame * h261_encap(struct fbuf_t *b, int mtu, struct ast_frame **tail)
static int h261_enc_init(AVCodecContext *enc_ctx)
static int h264_dec_init(AVCodecContext *dec_ctx)
static struct ast_frame * create_video_frame(uint8_t *start, uint8_t *end, int format, int head, struct ast_frame *prev)
static enum CodecID map_video_format(uint32_t ast_format, int rw)
map an asterisk format into an ffmpeg one
static int mpeg4_decap(struct fbuf_t *b, uint8_t *data, int len)
static int mpeg4_enc_init(AVCodecContext *enc_ctx)
static struct video_codec_desc mpeg4_codec
static struct ast_frame * h263p_encap(struct fbuf_t *b, int mtu, struct ast_frame **tail)
struct ast_frame *(* encoder_encap_f)(struct fbuf_t *, int mtu, struct ast_frame **tail)
encapsulate the bitstream in RTP frames
static struct video_dec_desc * dec_init(uint32_t the_ast_format)
static int fbuf_append(struct fbuf_t *b, uint8_t *src, int len, int sbit, int ebit)
static int h263p_decap(struct fbuf_t *b, uint8_t *data, int len)
extract the bitstream from the RTP payload. This is format dependent. For h263+, the format is define...
static struct ast_frame * h264_encap(struct fbuf_t *b, int mtu, struct ast_frame **tail)
static int h264_decap(struct fbuf_t *b, uint8_t *data, int len)
int(* encoder_init_f)(AVCodecContext *v)
initialize the encoder
static struct video_codec_desc h261_codec
static struct video_codec_desc * map_video_codec(int fmt)
int(* decoder_decode_f)(struct video_dec_desc *v, struct fbuf_t *b)
actually call the decoder
static const struct video_codec_desc * supported_codecs[]
int(* encoder_encode_f)(struct video_out_desc *v)
actually call the encoder
static struct video_codec_desc h263_codec
int(* decoder_init_f)(AVCodecContext *enc_ctx)
initialize the decoder
static struct video_dec_desc * dec_uninit(struct video_dec_desc *v)
uninitialize the descriptor for remote video stream