Originally committed as revision 17519 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -31,6 +31,7 @@ |
| 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,13 +400,24 @@ typedef struct RawDVContext {
|
| 399 | 399 |
static int dv_read_header(AVFormatContext *s, |
| 400 | 400 |
AVFormatParameters *ap) |
| 401 | 401 |
{
|
| 402 |
+ unsigned state; |
|
| 402 | 403 |
RawDVContext *c = s->priv_data; |
| 403 | 404 |
|
| 404 | 405 |
c->dv_demux = dv_init_demux(s); |
| 405 | 406 |
if (!c->dv_demux) |
| 406 | 407 |
return -1; |
| 407 | 408 |
|
| 408 |
- if (get_buffer(s->pb, c->buf, DV_PROFILE_BYTES) <= 0 || |
|
| 409 |
+ state = get_be32(s->pb); |
|
| 410 |
+ while ((state & 0xffffff7f) != 0x1f07003f) {
|
|
| 411 |
+ if (url_feof(s->pb)) {
|
|
| 412 |
+ av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n"); |
|
| 413 |
+ return -1; |
|
| 414 |
+ } |
|
| 415 |
+ state = (state << 8) | get_byte(s->pb); |
|
| 416 |
+ } |
|
| 417 |
+ AV_WB32(c->buf, state); |
|
| 418 |
+ |
|
| 419 |
+ if (get_buffer(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 || |
|
| 409 | 420 |
url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) |
| 410 | 421 |
return AVERROR(EIO); |
| 411 | 422 |
|