Showing the changes to libavcodec (3 of 3 files). Show all
Unified · Split
| @@ -119,6 +119,7 @@ typedef struct FFV1Context { · 118 unmodified lines | |||
| 119 | int64_t picture_number; | 119 | int64_t picture_number; |
| 120 | int key_frame; | 120 | int key_frame; |
| 121 | ProgressFrame picture, last_picture; | 121 | ProgressFrame picture, last_picture; |
| 122 | uint32_t crcref; | ||
| 122 | 123 | ||
| 123 | const AVFrame *cur_enc_frame; | 124 | const AVFrame *cur_enc_frame; |
| 124 | int plane_count; | 125 | int plane_count; |
| @@ -502,15 +502,17 @@ static int read_extra_header(FFV1Context *f) · 501 unmodified lines | |||
| 502 | 502 | ||
| 503 | if (f->version > 2) { | 503 | if (f->version > 2) { |
| 504 | f->ec = get_symbol(&c, state, 0); | 504 | f->ec = get_symbol(&c, state, 0); |
| 505 | if (f->ec >= 2) | ||
| 506 | f->crcref = 0x7a8c4079; | ||
| 505 | if (f->micro_version > 2) | 507 | if (f->micro_version > 2) |
| 506 | f->intra = get_symbol(&c, state, 0); | 508 | f->intra = get_symbol(&c, state, 0); |
| 507 | } | 509 | } |
| 508 | 510 | ||
| 509 | if (f->version > 2) { | 511 | if (f->version > 2) { |
| 510 | unsigned v; | 512 | unsigned v; |
| 511 | v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, | 513 | v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, |
| 512 | f->avctx->extradata, f->avctx->extradata_size); | 514 | f->avctx->extradata, f->avctx->extradata_size); |
| 513 | if (v || f->avctx->extradata_size < 4) { | 515 | if (v != f->crcref || f->avctx->extradata_size < 4) { |
| 514 | av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v); | 516 | av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v); |
| 515 | return AVERROR_INVALIDDATA; | 517 | return AVERROR_INVALIDDATA; |
| 516 | } | 518 | } |
| @@ -948,8 +950,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 431 unmodified lines | |||
| 948 | buf_p -= v; | 950 | buf_p -= v; |
| 949 | 951 | ||
| 950 | if (f->ec) { | 952 | if (f->ec) { |
| 951 | unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, buf_p, v); | 953 | unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, v); |
| 952 | if (crc) { | 954 | if (crc != f->crcref) { |
| 953 | int64_t ts = avpkt->pts != AV_NOPTS_VALUE ? avpkt->pts : avpkt->dts; | 955 | int64_t ts = avpkt->pts != AV_NOPTS_VALUE ? avpkt->pts : avpkt->dts; |
| 954 | av_log(f->avctx, AV_LOG_ERROR, "slice CRC mismatch %X!", crc); | 956 | av_log(f->avctx, AV_LOG_ERROR, "slice CRC mismatch %X!", crc); |
| 955 | if (ts != AV_NOPTS_VALUE && avctx->pkt_timebase.num) { | 957 | if (ts != AV_NOPTS_VALUE && avctx->pkt_timebase.num) { |
| @@ -458,7 +458,7 @@ static int write_extradata(FFV1Context *f) · 457 unmodified lines | |||
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | f->avctx->extradata_size = ff_rac_terminate(&c, 0); | 460 | f->avctx->extradata_size = ff_rac_terminate(&c, 0); |
| 461 | v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, f->avctx->extradata_size); | 461 | v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, f->avctx->extradata, f->avctx->extradata_size) ^ (f->crcref ? 0x8CD88196 : 0); |
| 462 | AV_WL32(f->avctx->extradata + f->avctx->extradata_size, v); | 462 | AV_WL32(f->avctx->extradata + f->avctx->extradata_size, v); |
| 463 | f->avctx->extradata_size += 4; | 463 | f->avctx->extradata_size += 4; |
| 464 | 464 | ||
| @@ -549,7 +549,13 @@ static av_cold int encode_init(AVCodecContext *avctx) · 84 unmodified lines | |||
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | if (s->ec < 0) { | 551 | if (s->ec < 0) { |
| 552 | s->ec = (s->version >= 3); | 552 | if (s->version >= 4) { |
| 553 | s->ec = 2; | ||
| 554 | s->crcref = 0x7a8c4079; | ||
| 555 | } else if (s->version >= 3) { | ||
| 556 | s->ec = 1; | ||
| 557 | } else | ||
| 558 | s->ec = 0; | ||
| 553 | } | 559 | } |
| 554 | 560 | ||
| 555 | // CRC requires version 3+ | 561 | // CRC requires version 3+ |
| @@ -1239,7 +1245,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 683 unmodified lines | |||
| 1239 | if (f->ec) { | 1245 | if (f->ec) { |
| 1240 | unsigned v; | 1246 | unsigned v; |
| 1241 | buf_p[bytes++] = 0; | 1247 | buf_p[bytes++] = 0; |
| 1242 | v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, buf_p, bytes); | 1248 | v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, bytes) ^ (f->crcref ? 0x8CD88196 : 0); |
| 1243 | AV_WL32(buf_p + bytes, v); | 1249 | AV_WL32(buf_p + bytes, v); |
| 1244 | bytes += 4; | 1250 | bytes += 4; |
| 1245 | } | 1251 | } |