Revision ec23a472 libavformat/mpeg.c

View differences:

libavformat/mpeg.c
405 405

  
406 406
static int mpegps_probe(AVProbeData *p)
407 407
{
408
    int code;
408
    int code, c, i;
409 409
    const uint8_t *d;
410 410

  
411
    code = 0xff;
411 412
    /* we search the first start code. If it is a packet start code,
412 413
       then we decide it is mpeg ps. We do not send highest value to
413 414
       give a chance to mpegts */
......
416 417

  
417 418
    if (p->buf_size < 6)
418 419
        return 0;
419
    d = p->buf;
420
    code = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]);
421
    if ((code & 0xffffff00) == 0x100) {
422
        if (code == PACK_START_CODE ||
423
            code == SYSTEM_HEADER_START_CODE ||
424
            (code >= 0x1e0 && code <= 0x1ef) ||
425
            (code >= 0x1c0 && code <= 0x1df) ||
426
            code == PRIVATE_STREAM_2 ||
427
            code == PROGRAM_STREAM_MAP ||
428
            code == PRIVATE_STREAM_1 ||
429
            code == PADDING_STREAM)
430
            return AVPROBE_SCORE_MAX - 1;
431
        else
432
            return 0;
420

  
421
    for (i = 0; i < 20; i++) {
422
        c = p->buf[i];
423
        code = (code << 8) | c;
424
        if ((code & 0xffffff00) == 0x100) {
425
            if (code == PACK_START_CODE ||
426
                code == SYSTEM_HEADER_START_CODE ||
427
                (code >= 0x1e0 && code <= 0x1ef) ||
428
                (code >= 0x1c0 && code <= 0x1df) ||
429
                code == PRIVATE_STREAM_2 ||
430
                code == PROGRAM_STREAM_MAP ||
431
                code == PRIVATE_STREAM_1 ||
432
                code == PADDING_STREAM)
433
                return AVPROBE_SCORE_MAX - 1;
434
            else
435
                return 0;
436
        }
433 437
    }
434 438
    return 0;
435 439
}

Also available in: Unified diff