~ubuntu-branches/ubuntu/lucid/ffmpeg/lucid-updates

« back to all changes in this revision

Viewing changes to libavformat/dv.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-03-13 09:18:28 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090313091828-n4ktby5eca487uhv
Tags: 3:0.svn20090303-1ubuntu1+unstripped1
merge from ubuntu.jaunty branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <time.h>
32
32
#include "avformat.h"
33
33
#include "libavcodec/dvdata.h"
 
34
#include "libavutil/intreadwrite.h"
34
35
#include "dv.h"
35
36
 
36
37
struct DVDemuxContext {
399
400
static int dv_read_header(AVFormatContext *s,
400
401
                          AVFormatParameters *ap)
401
402
{
 
403
    unsigned state;
402
404
    RawDVContext *c = s->priv_data;
403
405
 
404
406
    c->dv_demux = dv_init_demux(s);
405
407
    if (!c->dv_demux)
406
408
        return -1;
407
409
 
408
 
    if (get_buffer(s->pb, c->buf, DV_PROFILE_BYTES) <= 0 ||
 
410
    state = get_be32(s->pb);
 
411
    while ((state & 0xffffff7f) != 0x1f07003f) {
 
412
        if (url_feof(s->pb)) {
 
413
            av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
 
414
            return -1;
 
415
        }
 
416
        state = (state << 8) | get_byte(s->pb);
 
417
    }
 
418
    AV_WB32(c->buf, state);
 
419
 
 
420
    if (get_buffer(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 ||
409
421
        url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
410
422
        return AVERROR(EIO);
411
423
 
462
474
    return 0;
463
475
}
464
476
 
 
477
static int dv_probe(AVProbeData *p)
 
478
{
 
479
    unsigned state;
 
480
    int i;
 
481
 
 
482
    if (p->buf_size < 5)
 
483
        return 0;
 
484
 
 
485
    state = AV_RB32(p->buf);
 
486
    for (i = 4; i < p->buf_size; i++) {
 
487
        if ((state & 0xffffff7f) == 0x1f07003f)
 
488
            return AVPROBE_SCORE_MAX*3/4; // not max to avoid dv in mov to match
 
489
        state = (state << 8) | p->buf[i];
 
490
    }
 
491
 
 
492
    return 0;
 
493
}
 
494
 
465
495
#if CONFIG_DV_DEMUXER
466
496
AVInputFormat dv_demuxer = {
467
497
    "dv",
468
498
    NULL_IF_CONFIG_SMALL("DV video format"),
469
499
    sizeof(RawDVContext),
470
 
    NULL,
 
500
    dv_probe,
471
501
    dv_read_header,
472
502
    dv_read_packet,
473
503
    dv_read_close,