* qatar/master:
mpegaudiodec: Don't use a nonexistent log context for av_dlog
avformat: Accept the ISO8601 separate format as input, too
avformat: Interpret times in ff_iso8601_to_unix_time as UTC
avutil: Add av_timegm as a public function
cinepak: Add another special case so that it can handle the following file:
lagarith: add some RGBA decoding support
lagarith: Add correct line prediction for RGB
Conflicts:
doc/APIchanges
libavcodec/cinepak.c
libavutil/avutil.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -19,6 +19,9 @@ API changes, most recent first: |
| 19 | 19 |
2011-10-20 - b35e9e1 - lavu 51.22.0 |
| 20 | 20 |
Add av_strtok() to avstring.h. |
| 21 | 21 |
|
| 22 |
+2011-11-xx - xxxxxxx - lavu 51.16.0 |
|
| 23 |
+ Add av_timegm() |
|
| 24 |
+ |
|
| 22 | 25 |
2011-11-06 - ba04ecf - lavu 51.14.0 |
| 23 | 26 |
Add av_strcasecmp() and av_strncasecmp() to avstring.h. |
| 24 | 27 |
|
| ... | ... |
@@ -339,7 +339,7 @@ static int cinepak_decode (CinepakContext *s) |
| 339 | 339 |
* by the container file, this data likely comes from a Sega FILM/CPK file. |
| 340 | 340 |
* If the frame header is followed by the bytes FE 00 00 06 00 00 then |
| 341 | 341 |
* this is probably one of the two known files that have 6 extra bytes |
| 342 |
- * after the frame header. Else, assume 2 extra bytes. The container size |
|
| 342 |
+ * after the frame header. Else, assume 2 extra bytes. The container |
|
| 343 | 343 |
* size also cannot be a multiple of the encoded size. */ |
| 344 | 344 |
if (s->size >= 16 && |
| 345 | 345 |
(s->data[10] == 0xFE) && |
| ... | ... |
@@ -51,6 +51,8 @@ typedef struct LagarithContext {
|
| 51 | 51 |
DSPContext dsp; |
| 52 | 52 |
int zeros; /**< number of consecutive zero bytes encountered */ |
| 53 | 53 |
int zeros_rem; /**< number of zero bytes remaining to output */ |
| 54 |
+ uint8_t *rgb_planes; |
|
| 55 |
+ int rgb_stride; |
|
| 54 | 56 |
} LagarithContext; |
| 55 | 57 |
|
| 56 | 58 |
/** |
| ... | ... |
@@ -245,21 +247,21 @@ static void lag_pred_line(LagarithContext *l, uint8_t *buf, |
| 245 | 245 |
{
|
| 246 | 246 |
int L, TL; |
| 247 | 247 |
|
| 248 |
+ /* Left pixel is actually prev_row[width] */ |
|
| 249 |
+ L = buf[width - stride - 1]; |
|
| 248 | 250 |
if (!line) {
|
| 249 | 251 |
/* Left prediction only for first line */ |
| 250 | 252 |
L = l->dsp.add_hfyu_left_prediction(buf + 1, buf + 1, |
| 251 | 253 |
width - 1, buf[0]); |
| 252 | 254 |
return; |
| 253 | 255 |
} else if (line == 1) {
|
| 254 |
- /* Second line, left predict first pixel, the rest of the line is median predicted */ |
|
| 255 |
- /* FIXME: In the case of RGB this pixel is top predicted */ |
|
| 256 |
- TL = buf[-stride]; |
|
| 256 |
+ /* Second line, left predict first pixel, the rest of the line is median predicted |
|
| 257 |
+ * NOTE: In the case of RGB this pixel is top predicted */ |
|
| 258 |
+ TL = l->avctx->pix_fmt == PIX_FMT_YUV420P ? buf[-stride] : L; |
|
| 257 | 259 |
} else {
|
| 258 | 260 |
/* Top left is 2 rows back, last pixel */ |
| 259 | 261 |
TL = buf[width - (2 * stride) - 1]; |
| 260 | 262 |
} |
| 261 |
- /* Left pixel is actually prev_row[width] */ |
|
| 262 |
- L = buf[width - stride - 1]; |
|
| 263 | 263 |
|
| 264 | 264 |
add_lag_median_prediction(buf, buf - stride, buf, |
| 265 | 265 |
width, &L, &TL); |
| ... | ... |
@@ -443,6 +445,9 @@ static int lag_decode_frame(AVCodecContext *avctx, |
| 443 | 443 |
AVFrame *const p = &l->picture; |
| 444 | 444 |
uint8_t frametype = 0; |
| 445 | 445 |
uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9; |
| 446 |
+ int offs[4]; |
|
| 447 |
+ uint8_t *srcs[4], *dst; |
|
| 448 |
+ int i, j; |
|
| 446 | 449 |
|
| 447 | 450 |
AVFrame *picture = data; |
| 448 | 451 |
|
| ... | ... |
@@ -458,6 +463,67 @@ static int lag_decode_frame(AVCodecContext *avctx, |
| 458 | 458 |
offset_bv = AV_RL32(buf + 5); |
| 459 | 459 |
|
| 460 | 460 |
switch (frametype) {
|
| 461 |
+ case FRAME_SOLID_RGBA: |
|
| 462 |
+ avctx->pix_fmt = PIX_FMT_RGB32; |
|
| 463 |
+ |
|
| 464 |
+ if (avctx->get_buffer(avctx, p) < 0) {
|
|
| 465 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 466 |
+ return -1; |
|
| 467 |
+ } |
|
| 468 |
+ |
|
| 469 |
+ dst = p->data[0]; |
|
| 470 |
+ for (j = 0; j < avctx->height; j++) {
|
|
| 471 |
+ for (i = 0; i < avctx->width; i++) |
|
| 472 |
+ AV_WN32(dst + i * 4, offset_gu); |
|
| 473 |
+ dst += p->linesize[0]; |
|
| 474 |
+ } |
|
| 475 |
+ break; |
|
| 476 |
+ case FRAME_ARITH_RGBA: |
|
| 477 |
+ avctx->pix_fmt = PIX_FMT_RGB32; |
|
| 478 |
+ |
|
| 479 |
+ if (avctx->get_buffer(avctx, p) < 0) {
|
|
| 480 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 481 |
+ return -1; |
|
| 482 |
+ } |
|
| 483 |
+ offs[0] = offset_bv; |
|
| 484 |
+ offs[1] = offset_gu; |
|
| 485 |
+ offs[2] = 13; |
|
| 486 |
+ offs[3] = AV_RL32(buf + 9); |
|
| 487 |
+ |
|
| 488 |
+ if (!l->rgb_planes) {
|
|
| 489 |
+ l->rgb_stride = FFALIGN(avctx->width, 16); |
|
| 490 |
+ l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * 4); |
|
| 491 |
+ if (!l->rgb_planes) {
|
|
| 492 |
+ av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n"); |
|
| 493 |
+ return AVERROR(ENOMEM); |
|
| 494 |
+ } |
|
| 495 |
+ } |
|
| 496 |
+ for (i = 0; i < 4; i++) |
|
| 497 |
+ srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride; |
|
| 498 |
+ for (i = 0; i < 4; i++) |
|
| 499 |
+ lag_decode_arith_plane(l, srcs[i], |
|
| 500 |
+ avctx->width, avctx->height, |
|
| 501 |
+ -l->rgb_stride, buf + offs[i], |
|
| 502 |
+ buf_size); |
|
| 503 |
+ dst = p->data[0]; |
|
| 504 |
+ for (i = 0; i < 4; i++) |
|
| 505 |
+ srcs[i] = l->rgb_planes + i * l->rgb_stride * avctx->height; |
|
| 506 |
+ for (j = 0; j < avctx->height; j++) {
|
|
| 507 |
+ for (i = 0; i < avctx->width; i++) {
|
|
| 508 |
+ uint8_t r, g, b, a; |
|
| 509 |
+ r = srcs[0][i]; |
|
| 510 |
+ g = srcs[1][i]; |
|
| 511 |
+ b = srcs[2][i]; |
|
| 512 |
+ a = srcs[3][i]; |
|
| 513 |
+ r += g; |
|
| 514 |
+ b += g; |
|
| 515 |
+ AV_WN32(dst + i * 4, MKBETAG(a, r, g, b)); |
|
| 516 |
+ } |
|
| 517 |
+ dst += p->linesize[0]; |
|
| 518 |
+ for (i = 0; i < 4; i++) |
|
| 519 |
+ srcs[i] += l->rgb_stride; |
|
| 520 |
+ } |
|
| 521 |
+ break; |
|
| 461 | 522 |
case FRAME_ARITH_YV12: |
| 462 | 523 |
avctx->pix_fmt = PIX_FMT_YUV420P; |
| 463 | 524 |
|
| ... | ... |
@@ -504,6 +570,7 @@ static av_cold int lag_decode_end(AVCodecContext *avctx) |
| 504 | 504 |
|
| 505 | 505 |
if (l->picture.data[0]) |
| 506 | 506 |
avctx->release_buffer(avctx, &l->picture); |
| 507 |
+ av_freep(&l->rgb_planes); |
|
| 507 | 508 |
|
| 508 | 509 |
return 0; |
| 509 | 510 |
} |
| ... | ... |
@@ -33,6 +33,7 @@ |
| 33 | 33 |
#include "id3v2.h" |
| 34 | 34 |
#include "libavutil/avstring.h" |
| 35 | 35 |
#include "libavutil/mathematics.h" |
| 36 |
+#include "libavutil/parseutils.h" |
|
| 36 | 37 |
#include "riff.h" |
| 37 | 38 |
#include "audiointerleave.h" |
| 38 | 39 |
#include "url.h" |
| ... | ... |
@@ -4161,9 +4162,14 @@ void ff_make_absolute_url(char *buf, int size, const char *base, |
| 4161 | 4161 |
int64_t ff_iso8601_to_unix_time(const char *datestr) |
| 4162 | 4162 |
{
|
| 4163 | 4163 |
#if HAVE_STRPTIME |
| 4164 |
- struct tm time = {0};
|
|
| 4165 |
- strptime(datestr, "%Y - %m - %dT%T", &time); |
|
| 4166 |
- return mktime(&time); |
|
| 4164 |
+ struct tm time1 = {0}, time2 = {0};
|
|
| 4165 |
+ char *ret1, *ret2; |
|
| 4166 |
+ ret1 = strptime(datestr, "%Y - %m - %d %T", &time1); |
|
| 4167 |
+ ret2 = strptime(datestr, "%Y - %m - %dT%T", &time2); |
|
| 4168 |
+ if (ret2 && !ret1) |
|
| 4169 |
+ return av_timegm(&time2); |
|
| 4170 |
+ else |
|
| 4171 |
+ return av_timegm(&time1); |
|
| 4167 | 4172 |
#else |
| 4168 | 4173 |
av_log(NULL, AV_LOG_WARNING, "strptime() unavailable on this system, cannot convert " |
| 4169 | 4174 |
"the date string.\n"); |
| ... | ... |
@@ -40,7 +40,7 @@ |
| 40 | 40 |
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) |
| 41 | 41 |
|
| 42 | 42 |
#define LIBAVUTIL_VERSION_MAJOR 51 |
| 43 |
-#define LIBAVUTIL_VERSION_MINOR 25 |
|
| 43 |
+#define LIBAVUTIL_VERSION_MINOR 26 |
|
| 44 | 44 |
#define LIBAVUTIL_VERSION_MICRO 0 |
| 45 | 45 |
|
| 46 | 46 |
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| ... | ... |
@@ -471,7 +471,7 @@ static const char *small_strptime(const char *p, const char *fmt, struct tm *dt) |
| 471 | 471 |
} |
| 472 | 472 |
} |
| 473 | 473 |
|
| 474 |
-static time_t mktimegm(struct tm *tm) |
|
| 474 |
+time_t av_timegm(struct tm *tm) |
|
| 475 | 475 |
{
|
| 476 | 476 |
time_t t; |
| 477 | 477 |
|
| ... | ... |
@@ -592,7 +592,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) |
| 592 | 592 |
} else {
|
| 593 | 593 |
dt.tm_isdst = -1; /* unknown */ |
| 594 | 594 |
if (is_utc) {
|
| 595 |
- t = mktimegm(&dt); |
|
| 595 |
+ t = av_timegm(&dt); |
|
| 596 | 596 |
} else {
|
| 597 | 597 |
t = mktime(&dt); |
| 598 | 598 |
} |
| ... | ... |
@@ -19,6 +19,8 @@ |
| 19 | 19 |
#ifndef AVUTIL_PARSEUTILS_H |
| 20 | 20 |
#define AVUTIL_PARSEUTILS_H |
| 21 | 21 |
|
| 22 |
+#include <time.h> |
|
| 23 |
+ |
|
| 22 | 24 |
#include "rational.h" |
| 23 | 25 |
|
| 24 | 26 |
/** |
| ... | ... |
@@ -114,4 +116,9 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration); |
| 114 | 114 |
*/ |
| 115 | 115 |
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); |
| 116 | 116 |
|
| 117 |
+/** |
|
| 118 |
+ * Convert the decomposed UTC time in tm to a time_t value. |
|
| 119 |
+ */ |
|
| 120 |
+time_t av_timegm(struct tm *tm); |
|
| 121 |
+ |
|
| 117 | 122 |
#endif /* AVUTIL_PARSEUTILS_H */ |