parser.h File Reference

#include "avcodec.h"

Go to the source code of this file.

Data Structures

struct  ParseContext
struct  ParseContext1

Defines

#define END_NOT_FOUND   (-100)

Functions

int ff_combine_frame (ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
int ff_mpeg4video_split (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
void ff_parse_close (AVCodecParserContext *s)
void ff_parse1_close (AVCodecParserContext *s)
void ff_fetch_timestamp (AVCodecParserContext *s, int off, int remove)


Define Documentation

#define END_NOT_FOUND   (-100)

Definition at line 54 of file parser.h.

Referenced by cavs_find_frame_end(), decode_frame(), ff_aac_ac3_parse(), ff_combine_frame(), ff_h263_find_frame_end(), ff_mpeg4_find_frame_end(), find_frame_end(), h261_find_frame_end(), h264_parse(), mlp_parse(), and vc1_find_frame_end().


Function Documentation

int ff_combine_frame ( ParseContext pc,
int  next,
const uint8_t **  buf,
int *  buf_size 
)

combines the (truncated) bitstream to a complete frame

Returns:
-1 if no complete frame could be created, AVERROR(ENOMEM) if there was a memory allocation error

Definition at line 226 of file parser.c.

References av_fast_realloc(), AVERROR, ParseContext::buffer, ParseContext::buffer_size, END_NOT_FOUND, FF_INPUT_BUFFER_PADDING_SIZE, ParseContext::index, ParseContext::last_index, ParseContext::overread, ParseContext::overread_index, printf, and ParseContext::state.

Referenced by cavsvideo_parse(), dca_parse(), decode_frame(), dirac_parse(), ff_aac_ac3_parse(), ff_h263_decode_frame(), h261_parse(), h263_parse(), h264_parse(), jpeg_parse(), mlp_parse(), mpeg4video_parse(), mpeg_decode_frame(), mpegvideo_parse(), and vc1_parse().

00227 {
00228 #if 0
00229     if(pc->overread){
00230         printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
00231         printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
00232     }
00233 #endif
00234 
00235     /* Copy overread bytes from last frame into buffer. */
00236     for(; pc->overread>0; pc->overread--){
00237         pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
00238     }
00239 
00240     /* flush remaining if EOF */
00241     if(!*buf_size && next == END_NOT_FOUND){
00242         next= 0;
00243     }
00244 
00245     pc->last_index= pc->index;
00246 
00247     /* copy into buffer end return */
00248     if(next == END_NOT_FOUND){
00249         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
00250 
00251         if(!new_buffer)
00252             return AVERROR(ENOMEM);
00253         pc->buffer = new_buffer;
00254         memcpy(&pc->buffer[pc->index], *buf, *buf_size);
00255         pc->index += *buf_size;
00256         return -1;
00257     }
00258 
00259     *buf_size=
00260     pc->overread_index= pc->index + next;
00261 
00262     /* append to buffer */
00263     if(pc->index){
00264         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
00265 
00266         if(!new_buffer)
00267             return AVERROR(ENOMEM);
00268         pc->buffer = new_buffer;
00269         memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
00270         pc->index = 0;
00271         *buf= pc->buffer;
00272     }
00273 
00274     /* store overread bytes */
00275     for(;next < 0; next++){
00276         pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
00277         pc->overread++;
00278     }
00279 
00280 #if 0
00281     if(pc->overread){
00282         printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
00283         printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
00284     }
00285 #endif
00286 
00287     return 0;
00288 }

void ff_fetch_timestamp ( AVCodecParserContext s,
int  off,
int  remove 
)

Fetches timestamps for a specific byte within the current access unit.

Parameters:
off byte position within the access unit
remove Found timestamps will be removed if set to 1, kept if set to 0.

Definition at line 79 of file parser.c.

References AV_NOPTS_VALUE, AV_PARSER_PTS_NB, AVCodecParserContext::cur_frame_dts, AVCodecParserContext::cur_frame_end, AVCodecParserContext::cur_frame_offset, AVCodecParserContext::cur_frame_pts, AVCodecParserContext::dts, AVCodecParserContext::frame_offset, INT64_MAX, AVCodecParserContext::next_frame_offset, AVCodecParserContext::offset, and AVCodecParserContext::pts.

Referenced by av_parser_parse(), and mpegvideo_extract_headers().

00079                                                                      {
00080     int i;
00081 
00082     s->dts= s->pts= AV_NOPTS_VALUE;
00083     s->offset= 0;
00084     for(i = 0; i < AV_PARSER_PTS_NB; i++) {
00085         if (   s->next_frame_offset + off >= s->cur_frame_offset[i]
00086             &&(s->     frame_offset       <  s->cur_frame_offset[i] || !s->frame_offset)
00087             //check is disabled  becausue mpeg-ts doesnt send complete PES packets
00088             && /*s->next_frame_offset + off <*/  s->cur_frame_end[i]){
00089             s->dts= s->cur_frame_dts[i];
00090             s->pts= s->cur_frame_pts[i];
00091             s->offset = s->next_frame_offset - s->cur_frame_offset[i];
00092             if(remove)
00093                 s->cur_frame_offset[i]= INT64_MAX;
00094         }
00095     }
00096 }

int ff_mpeg4video_split ( AVCodecContext avctx,
const uint8_t *  buf,
int  buf_size 
)

Definition at line 307 of file parser.c.

00309 {
00310     int i;
00311     uint32_t state= -1;
00312 
00313     for(i=0; i<buf_size; i++){
00314         state= (state<<8) | buf[i];
00315         if(state == 0x1B3 || state == 0x1B6)
00316             return i-3;
00317     }
00318     return 0;
00319 }

void ff_parse1_close ( AVCodecParserContext s  ) 

Definition at line 297 of file parser.c.

References av_free(), ParseContext::buffer, ParseContext1::enc, ParseContext1::pc, and AVCodecParserContext::priv_data.

00298 {
00299     ParseContext1 *pc1 = s->priv_data;
00300 
00301     av_free(pc1->pc.buffer);
00302     av_free(pc1->enc);
00303 }

void ff_parse_close ( AVCodecParserContext s  ) 

Definition at line 290 of file parser.c.

References av_free(), ParseContext::buffer, and AVCodecParserContext::priv_data.

00291 {
00292     ParseContext *pc = s->priv_data;
00293 
00294     av_free(pc->buffer);
00295 }


Generated on Thu Nov 20 07:45:46 2008 for libextractor by  doxygen 1.5.1