diff options
Diffstat (limited to 'libavcodec/parser.c')
-rw-r--r-- | libavcodec/parser.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 7ace766eb9..2e204e2c2a 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -40,7 +40,7 @@ void av_register_codec_parser(AVCodecParser *parser) AVCodecParserContext *av_parser_init(int codec_id) { - AVCodecParserContext *s; + AVCodecParserContext *s = NULL; AVCodecParser *parser; int ret; @@ -59,31 +59,30 @@ AVCodecParserContext *av_parser_init(int codec_id) found: s = av_mallocz(sizeof(AVCodecParserContext)); if (!s) - return NULL; + goto err_out; s->parser = parser; - if (parser->priv_data_size) { - s->priv_data = av_mallocz(parser->priv_data_size); - if (!s->priv_data) { - av_free(s); - return NULL; - } - } + s->priv_data = av_mallocz(parser->priv_data_size); + if (!s->priv_data) + goto err_out; + s->fetch_timestamp=1; + s->pict_type = AV_PICTURE_TYPE_I; if (parser->parser_init) { ret = parser->parser_init(s); - if (ret != 0) { - av_free(s->priv_data); - av_free(s); - return NULL; - } + if (ret != 0) + goto err_out; } - s->fetch_timestamp=1; - s->pict_type = AV_PICTURE_TYPE_I; s->key_frame = -1; s->convergence_duration = 0; s->dts_sync_point = INT_MIN; s->dts_ref_dts_delta = INT_MIN; s->pts_dts_delta = INT_MIN; return s; + +err_out: + if (s) + av_freep(&s->priv_data); + av_free(s); + return NULL; } void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){ @@ -96,7 +95,7 @@ void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){ if ( s->cur_offset + off >= s->cur_frame_offset[i] && (s->frame_offset < s->cur_frame_offset[i] || (!s->frame_offset && !s->next_frame_offset)) // first field/frame - //check is disabled because mpeg-ts doesnt send complete PES packets + //check is disabled because mpeg-ts doesn't send complete PES packets && /*s->next_frame_offset + off <*/ s->cur_frame_end[i]){ s->dts= s->cur_frame_dts[i]; s->pts= s->cur_frame_pts[i]; @@ -254,6 +253,7 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s if(!new_buffer) return AVERROR(ENOMEM); pc->buffer = new_buffer; + if(FF_INPUT_BUFFER_PADDING_SIZE > -next) memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); pc->index = 0; *buf= pc->buffer; |