#include "libavutil/attributes.h"
#include "libavutil/channel_layout.h"
-#include "libavutil/display.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/mathematics.h"
#include "libavutil/time_internal.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
+#include "libavutil/display.h"
#include "libavutil/opt.h"
#include "libavutil/timecode.h"
#include "libavcodec/ac3tab.h"
return mov_read_extradata(c, pb, atom, AV_CODEC_ID_JPEG2000);
}
+static int mov_read_dpxe(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+ return mov_read_extradata(c, pb, atom, AV_CODEC_ID_R10K);
+}
+
static int mov_read_avid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int ret = mov_read_extradata(c, pb, atom, AV_CODEC_ID_AVUI);
st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE;
st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */
st->codec->time_base.num = 1;
+ /* adjust for per frame dur in counter mode */
+ if (tmcd_ctx->tmcd_flags & 0x0008) {
+ int timescale = AV_RB32(st->codec->extradata + 8);
+ int framedur = AV_RB32(st->codec->extradata + 12);
+ st->codec->time_base.den *= timescale;
+ st->codec->time_base.num *= framedur;
+ }
if (size > 30) {
uint32_t len = AV_RB32(st->codec->extradata + 18); /* name atom length */
uint32_t format = AV_RB32(st->codec->extradata + 22);
int i;
int width;
int height;
- int64_t disp_transform[2];
int display_matrix[3][3];
AVStream *st;
MOVStreamContext *sc;
}
// transform the display width/height according to the matrix
- // skip this if the display matrix is the default identity matrix
- // or if it is rotating the picture, ex iPhone 3GS
// to keep the same scale, use [width height 1<<16]
- if (width && height &&
- ((display_matrix[0][0] != 65536 ||
- display_matrix[1][1] != 65536) &&
- !display_matrix[0][1] &&
- !display_matrix[1][0] &&
- !display_matrix[2][0] && !display_matrix[2][1])) {
+ if (width && height && sc->display_matrix) {
+ double disp_transform[2];
+
+#define SQR(a) ((a)*(double)(a))
for (i = 0; i < 2; i++)
- disp_transform[i] =
- (int64_t) width * display_matrix[0][i] +
- (int64_t) height * display_matrix[1][i] +
- ((int64_t) display_matrix[2][i] << 16);
-
- //sample aspect ratio is new width/height divided by old width/height
- st->sample_aspect_ratio = av_d2q(
- ((double) disp_transform[0] * height) /
- ((double) disp_transform[1] * width), INT_MAX);
+ disp_transform[i] = sqrt(SQR(display_matrix[i][0]) + SQR(display_matrix[i][1]));
+
+ if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
+ disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
+ fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
+ st->sample_aspect_ratio = av_d2q(
+ disp_transform[0] / disp_transform[1],
+ INT_MAX);
}
return 0;
}
{ MKTAG('c','o','l','r'), mov_read_colr },
{ MKTAG('c','t','t','s'), mov_read_ctts }, /* composition time to sample */
{ MKTAG('d','i','n','f'), mov_read_default },
+{ MKTAG('D','p','x','E'), mov_read_dpxe },
{ MKTAG('d','r','e','f'), mov_read_dref },
{ MKTAG('e','d','t','s'), mov_read_default },
{ MKTAG('e','l','s','t'), mov_read_elst },
sc->drefs_count = 0;
if (!sc->pb_is_copied)
- avio_close(sc->pb);
+ avio_closep(&sc->pb);
sc->pb = NULL;
av_freep(&sc->chunk_offsets);