~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/parser.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
21
 */
22
22
 
 
23
#include <string.h>
 
24
 
23
25
#include "parser.h"
 
26
#include "libavutil/mem.h"
24
27
 
25
28
static AVCodecParser *av_first_parser = NULL;
26
29
 
41
44
    AVCodecParser *parser;
42
45
    int ret;
43
46
 
44
 
    if(codec_id == CODEC_ID_NONE)
 
47
    if(codec_id == AV_CODEC_ID_NONE)
45
48
        return NULL;
46
49
 
47
50
    for(parser = av_first_parser; parser != NULL; parser = parser->next) {
93
96
        if (   s->cur_offset + off >= s->cur_frame_offset[i]
94
97
            && (s->frame_offset < s->cur_frame_offset[i] ||
95
98
              (!s->frame_offset && !s->next_frame_offset)) // first field/frame
96
 
            //check is disabled  because mpeg-ts doesnt send complete PES packets
 
99
            // check disabled since MPEG-TS does not send complete PES packets
97
100
            && /*s->next_frame_offset + off <*/  s->cur_frame_end[i]){
98
101
            s->dts= s->cur_frame_dts[i];
99
102
            s->pts= s->cur_frame_pts[i];
149
152
 
150
153
    /* WARNING: the returned index can be negative */
151
154
    index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, poutbuf_size, buf, buf_size);
152
 
//av_log(NULL, AV_LOG_DEBUG, "parser: in:%"PRId64", %"PRId64", out:%"PRId64", %"PRId64", in:%d out:%d id:%d\n", pts, dts, s->last_pts, s->last_dts, buf_size, *poutbuf_size, avctx->codec_id);
153
155
    /* update the file pointer */
154
156
    if (*poutbuf_size) {
155
157
        /* fill the data for the current frame */
165
167
    return index;
166
168
}
167
169
 
168
 
/**
169
 
 *
170
 
 * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
171
 
 * @deprecated use AVBitstreamFilter
172
 
 */
173
170
int av_parser_change(AVCodecParserContext *s,
174
171
                     AVCodecContext *avctx,
175
172
                     uint8_t **poutbuf, int *poutbuf_size,
215
212
 
216
213
/*****************************************************/
217
214
 
218
 
/**
219
 
 * Combine the (truncated) bitstream to a complete frame.
220
 
 * @return -1 if no complete frame could be created, AVERROR(ENOMEM) if there was a memory allocation error
221
 
 */
222
215
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
223
216
{
224
217
    if(pc->overread){
225
 
        av_dlog(pc, "overread %d, state:%X next:%d index:%d o_index:%d\n",
 
218
        av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
226
219
                pc->overread, pc->state, next, pc->index, pc->overread_index);
227
 
        av_dlog(pc, "%X %X %X %X\n", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
 
220
        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
228
221
    }
229
222
 
230
223
    /* Copy overread bytes from last frame into buffer. */
276
269
    }
277
270
 
278
271
    if(pc->overread){
279
 
        av_dlog(pc, "overread %d, state:%X next:%d index:%d o_index:%d\n",
 
272
        av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
280
273
                pc->overread, pc->state, next, pc->index, pc->overread_index);
281
 
        av_dlog(pc, "%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
 
274
        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
282
275
    }
283
276
 
284
277
    return 0;
291
284
    av_freep(&pc->buffer);
292
285
}
293
286
 
294
 
void ff_parse1_close(AVCodecParserContext *s)
295
 
{
296
 
    ParseContext1 *pc1 = s->priv_data;
297
 
 
298
 
    av_free(pc1->pc.buffer);
299
 
    av_free(pc1->enc);
300
 
}
301
 
 
302
287
/*************************/
303
288
 
304
289
int ff_mpeg4video_split(AVCodecContext *avctx,