mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-14 22:22:59 +02:00
cleanup
Originally committed as revision 1487 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
68f593b484
commit
b7a22d846b
@ -1236,6 +1236,7 @@ void *av_mallocz(unsigned int size);
|
|||||||
void av_free(void *ptr);
|
void av_free(void *ptr);
|
||||||
void __av_freep(void **ptr);
|
void __av_freep(void **ptr);
|
||||||
#define av_freep(p) __av_freep((void **)(p))
|
#define av_freep(p) __av_freep((void **)(p))
|
||||||
|
void *av_fast_realloc(void *ptr, int *size, int min_size);
|
||||||
/* for static data only */
|
/* for static data only */
|
||||||
/* call av_free_static to release all staticaly allocated tables */
|
/* call av_free_static to release all staticaly allocated tables */
|
||||||
void av_free_static(void);
|
void av_free_static(void);
|
||||||
|
@ -401,41 +401,19 @@ uint64_t time= rdtsc();
|
|||||||
if (buf_size == 0) {
|
if (buf_size == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->flags&CODEC_FLAG_TRUNCATED){
|
if(s->flags&CODEC_FLAG_TRUNCATED){
|
||||||
int next;
|
int next;
|
||||||
ParseContext *pc= &s->parse_context;
|
|
||||||
|
|
||||||
pc->last_index= pc->index;
|
|
||||||
|
|
||||||
if(s->codec_id==CODEC_ID_MPEG4){
|
if(s->codec_id==CODEC_ID_MPEG4){
|
||||||
next= mpeg4_find_frame_end(s, buf, buf_size);
|
next= mpeg4_find_frame_end(s, buf, buf_size);
|
||||||
}else{
|
}else{
|
||||||
fprintf(stderr, "this codec doesnt support truncated bitstreams\n");
|
fprintf(stderr, "this codec doesnt support truncated bitstreams\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(next==-1){
|
|
||||||
if(buf_size + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){
|
if( ff_combine_frame(s, next, &buf, &buf_size) < 0 )
|
||||||
pc->buffer_size= buf_size + pc->index + 10*1024;
|
|
||||||
pc->buffer= realloc(pc->buffer, pc->buffer_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&pc->buffer[pc->index], buf, buf_size);
|
|
||||||
pc->index += buf_size;
|
|
||||||
return buf_size;
|
return buf_size;
|
||||||
}
|
|
||||||
|
|
||||||
if(pc->index){
|
|
||||||
if(next + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){
|
|
||||||
pc->buffer_size= next + pc->index + 10*1024;
|
|
||||||
pc->buffer= realloc(pc->buffer, pc->buffer_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&pc->buffer[pc->index], buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
|
|
||||||
pc->index = 0;
|
|
||||||
buf= pc->buffer;
|
|
||||||
buf_size= pc->last_index + next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
|
@ -71,6 +71,17 @@ void *av_malloc(unsigned int size)
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* realloc which does nothing if the block is large enogh
|
||||||
|
*/
|
||||||
|
void *av_fast_realloc(void *ptr, int *size, int min_size){
|
||||||
|
if(min_size < *size) return ptr;
|
||||||
|
|
||||||
|
*size= min_size + 10*1024;
|
||||||
|
|
||||||
|
return realloc(ptr, *size);
|
||||||
|
}
|
||||||
|
|
||||||
/* NOTE: ptr = NULL is explicetly allowed */
|
/* NOTE: ptr = NULL is explicetly allowed */
|
||||||
void av_free(void *ptr)
|
void av_free(void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -2627,6 +2627,35 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* combines the (truncated) bitstream to a complete frame
|
||||||
|
* @returns -1 if no complete frame could be created
|
||||||
|
*/
|
||||||
|
int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size){
|
||||||
|
ParseContext *pc= &s->parse_context;
|
||||||
|
|
||||||
|
pc->last_index= pc->index;
|
||||||
|
|
||||||
|
if(next==-1){
|
||||||
|
pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
|
memcpy(&pc->buffer[pc->index], *buf, *buf_size);
|
||||||
|
pc->index += *buf_size;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pc->index){
|
||||||
|
pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
|
memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
|
||||||
|
pc->index = 0;
|
||||||
|
*buf= pc->buffer;
|
||||||
|
*buf_size= pc->last_index + next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length)
|
void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length)
|
||||||
{
|
{
|
||||||
int bytes= length>>4;
|
int bytes= length>>4;
|
||||||
|
@ -604,6 +604,7 @@ void ff_draw_horiz_band(MpegEncContext *s);
|
|||||||
void ff_emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int block_w, int block_h,
|
void ff_emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int block_w, int block_h,
|
||||||
int src_x, int src_y, int w, int h);
|
int src_x, int src_y, int w, int h);
|
||||||
char ff_get_pict_type_char(int pict_type);
|
char ff_get_pict_type_char(int pict_type);
|
||||||
|
int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size);
|
||||||
|
|
||||||
extern enum PixelFormat ff_yuv420p_list[2];
|
extern enum PixelFormat ff_yuv420p_list[2];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user