Merge remote-tracking branch 'cehoyos/master'
* cehoyos/master: Set bits_per_raw_sample when reading j2k frames. libopenjpegdec.c: Correctly scale gray16 output if precision < 16 Use rc_max_rate if no video bit_rate was specified when muxing mxf_d10. Store the video bit_rate in the context when muxing mxf. Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
e2774b3e3b
@ -350,6 +350,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
|||||||
ncomponents > 2 ? s->cdx[2] : 0,
|
ncomponents > 2 ? s->cdx[2] : 0,
|
||||||
ncomponents > 2 ? s->cdy[2] : 0);
|
ncomponents > 2 ? s->cdy[2] : 0);
|
||||||
}
|
}
|
||||||
|
s->avctx->bits_per_raw_sample = s->precision;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,12 +207,16 @@ static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
|
|||||||
int *comp_data;
|
int *comp_data;
|
||||||
uint16_t *img_ptr;
|
uint16_t *img_ptr;
|
||||||
int index, x, y;
|
int index, x, y;
|
||||||
|
int adjust[4];
|
||||||
|
for (x = 0; x < image->numcomps; x++)
|
||||||
|
adjust[x] = FFMAX(FFMIN(16 - image->comps[x].prec, 8), 0);
|
||||||
|
|
||||||
for (index = 0; index < image->numcomps; index++) {
|
for (index = 0; index < image->numcomps; index++) {
|
||||||
comp_data = image->comps[index].data;
|
comp_data = image->comps[index].data;
|
||||||
for (y = 0; y < image->comps[index].h; y++) {
|
for (y = 0; y < image->comps[index].h; y++) {
|
||||||
img_ptr = (uint16_t*) (picture->data[index] + y * picture->linesize[index]);
|
img_ptr = (uint16_t*) (picture->data[index] + y * picture->linesize[index]);
|
||||||
for (x = 0; x < image->comps[index].w; x++) {
|
for (x = 0; x < image->comps[index].w; x++) {
|
||||||
*img_ptr = *comp_data;
|
*img_ptr = *comp_data << adjust[index];
|
||||||
img_ptr++;
|
img_ptr++;
|
||||||
comp_data++;
|
comp_data++;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ typedef struct {
|
|||||||
int temporal_reordering;
|
int temporal_reordering;
|
||||||
AVRational aspect_ratio; ///< display aspect ratio
|
AVRational aspect_ratio; ///< display aspect ratio
|
||||||
int closed_gop; ///< gop is closed, used in mpeg-2 frame parsing
|
int closed_gop; ///< gop is closed, used in mpeg-2 frame parsing
|
||||||
|
int video_bit_rate;
|
||||||
} MXFStreamContext;
|
} MXFStreamContext;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -976,13 +977,14 @@ static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
|
|||||||
static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
|
static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
|
||||||
{
|
{
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
|
MXFStreamContext *sc = st->priv_data;
|
||||||
int profile_and_level = (st->codec->profile<<4) | st->codec->level;
|
int profile_and_level = (st->codec->profile<<4) | st->codec->level;
|
||||||
|
|
||||||
mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key, 8+5);
|
mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key, 8+5);
|
||||||
|
|
||||||
// bit rate
|
// bit rate
|
||||||
mxf_write_local_tag(pb, 4, 0x8000);
|
mxf_write_local_tag(pb, 4, 0x8000);
|
||||||
avio_wb32(pb, st->codec->bit_rate);
|
avio_wb32(pb, sc->video_bit_rate);
|
||||||
|
|
||||||
// profile and level
|
// profile and level
|
||||||
mxf_write_local_tag(pb, 1, 0x8007);
|
mxf_write_local_tag(pb, 1, 0x8007);
|
||||||
@ -1708,14 +1710,15 @@ static int mxf_write_header(AVFormatContext *s)
|
|||||||
ret = av_timecode_init(&mxf->tc, rate, 0, 0, s);
|
ret = av_timecode_init(&mxf->tc, rate, 0, 0, s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
sc->video_bit_rate = st->codec->bit_rate ? st->codec->bit_rate : st->codec->rc_max_rate;
|
||||||
if (s->oformat == &ff_mxf_d10_muxer) {
|
if (s->oformat == &ff_mxf_d10_muxer) {
|
||||||
if (st->codec->bit_rate == 50000000) {
|
if (sc->video_bit_rate == 50000000) {
|
||||||
if (mxf->time_base.den == 25) sc->index = 3;
|
if (mxf->time_base.den == 25) sc->index = 3;
|
||||||
else sc->index = 5;
|
else sc->index = 5;
|
||||||
} else if (st->codec->bit_rate == 40000000) {
|
} else if (sc->video_bit_rate == 40000000) {
|
||||||
if (mxf->time_base.den == 25) sc->index = 7;
|
if (mxf->time_base.den == 25) sc->index = 7;
|
||||||
else sc->index = 9;
|
else sc->index = 9;
|
||||||
} else if (st->codec->bit_rate == 30000000) {
|
} else if (sc->video_bit_rate == 30000000) {
|
||||||
if (mxf->time_base.den == 25) sc->index = 11;
|
if (mxf->time_base.den == 25) sc->index = 11;
|
||||||
else sc->index = 13;
|
else sc->index = 13;
|
||||||
} else {
|
} else {
|
||||||
@ -1724,7 +1727,7 @@ static int mxf_write_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mxf->edit_unit_byte_count = KAG_SIZE; // system element
|
mxf->edit_unit_byte_count = KAG_SIZE; // system element
|
||||||
mxf->edit_unit_byte_count += 16 + 4 + (uint64_t)st->codec->bit_rate *
|
mxf->edit_unit_byte_count += 16 + 4 + (uint64_t)sc->video_bit_rate *
|
||||||
mxf->time_base.num / (8*mxf->time_base.den);
|
mxf->time_base.num / (8*mxf->time_base.den);
|
||||||
mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
|
mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
|
||||||
mxf->edit_unit_byte_count += 16 + 4 + 4 + spf->samples_per_frame[0]*8*4;
|
mxf->edit_unit_byte_count += 16 + 4 + 4 + spf->samples_per_frame[0]*8*4;
|
||||||
@ -1858,7 +1861,8 @@ static void mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacke
|
|||||||
{
|
{
|
||||||
MXFContext *mxf = s->priv_data;
|
MXFContext *mxf = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
int packet_size = (uint64_t)st->codec->bit_rate*mxf->time_base.num /
|
MXFStreamContext *sc = st->priv_data;
|
||||||
|
int packet_size = (uint64_t)sc->video_bit_rate*mxf->time_base.num /
|
||||||
(8*mxf->time_base.den); // frame size
|
(8*mxf->time_base.den); // frame size
|
||||||
int pad;
|
int pad;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user