aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/gxfenc.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:58:15 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:59:55 +0100
commit6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch)
tree0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/gxfenc.c
parent60b75186b2c878b6257b43c8fcc0b1356ada218e (diff)
parent9200514ad8717c63f82101dc394f4378854325bf (diff)
downloadffmpeg-6f69f7a8bf6a0d013985578df2ef42ee6b1c7994.tar.gz
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf': lavf: replace AVStream.codec with AVStream.codecpar This has been a HUGE effort from: - Derek Buitenhuis <derek.buitenhuis@gmail.com> - Hendrik Leppkes <h.leppkes@gmail.com> - wm4 <nfxjfg@googlemail.com> - Clément Bœsch <clement@stupeflix.com> - James Almer <jamrial@gmail.com> - Michael Niedermayer <michael@niedermayer.cc> - Rostislav Pehlivanov <atomnuker@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat/gxfenc.c')
-rw-r--r--libavformat/gxfenc.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 8229fe9500..0a40ded2bd 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -124,7 +124,7 @@ static int gxf_find_lines_index(AVStream *st)
int i;
for (i = 0; i < 6; ++i) {
- if (st->codec->height == gxf_lines_tab[i].height) {
+ if (st->codecpar->height == gxf_lines_tab[i].height) {
sc->lines_index = gxf_lines_tab[i].index;
return 0;
}
@@ -198,18 +198,18 @@ static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st)
if (sc->b_per_i_or_p > 9)
sc->b_per_i_or_p = 9; /* ensure value won't take more than one char */
}
- if (st->codec->height == 512 || st->codec->height == 608)
+ if (st->codecpar->height == 512 || st->codecpar->height == 608)
starting_line = 7; // VBI
- else if (st->codec->height == 480)
+ else if (st->codecpar->height == 480)
starting_line = 20;
else
starting_line = 23; // default PAL
size = snprintf(buffer, sizeof(buffer), "Ver 1\nBr %.6f\nIpg 1\nPpi %d\nBpiop %d\n"
"Pix 0\nCf %d\nCg %d\nSl %d\nnl16 %d\nVi 1\nf1 1\n",
- (float)st->codec->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
- st->codec->pix_fmt == AV_PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
- starting_line, (st->codec->height + 15) / 16);
+ (float)st->codecpar->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
+ st->codecpar->format == AV_PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
+ starting_line, (st->codecpar->height + 15) / 16);
av_assert0(size < sizeof(buffer));
avio_w8(pb, TRACK_MPG_AUX);
avio_w8(pb, size + 1);
@@ -223,7 +223,7 @@ static int gxf_write_dv_auxiliary(AVIOContext *pb, AVStream *st)
avio_w8(pb, TRACK_AUX);
avio_w8(pb, 8);
- if (st->codec->pix_fmt == AV_PIX_FMT_YUV420P)
+ if (st->codecpar->format == AV_PIX_FMT_YUV420P)
track_aux_data |= 0x01; /* marks stream as DVCAM instead of DVPRO */
track_aux_data |= 0x40000000; /* aux data is valid */
avio_wl64(pb, track_aux_data);
@@ -520,7 +520,7 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
{
GXFStreamContext *sc = st->priv_data;
- if (st->codec->pix_fmt == AV_PIX_FMT_YUV422P)
+ if (st->codecpar->format == AV_PIX_FMT_YUV422P)
avio_wl32(pb, 2);
else
avio_wl32(pb, 1); /* default to 420 */
@@ -529,9 +529,9 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
avio_wl32(pb, 1); /* I picture per GOP */
avio_wl32(pb, sc->p_per_gop);
avio_wl32(pb, sc->b_per_i_or_p);
- if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
avio_wl32(pb, 2);
- else if (st->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO)
+ else if (st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO)
avio_wl32(pb, 1);
else
avio_wl32(pb, 0);
@@ -556,7 +556,7 @@ static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc, AVStrea
{
int dv_umf_data = 0;
- if (st->codec->pix_fmt == AV_PIX_FMT_YUV420P)
+ if (st->codecpar->format == AV_PIX_FMT_YUV420P)
dv_umf_data |= 0x20; /* marks as DVCAM instead of DVPRO */
avio_wl32(pb, dv_umf_data);
avio_wl32(pb, 0);
@@ -620,7 +620,7 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
gxf_write_umf_media_timecode(pb, gxf->tc.drop);
else {
AVStream *st = s->streams[i];
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
gxf_write_umf_media_mpeg(pb, st);
@@ -722,22 +722,22 @@ static int gxf_write_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->priv_data = sc;
- sc->media_type = ff_codec_get_tag(gxf_media_types, st->codec->codec_id);
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (st->codec->codec_id != AV_CODEC_ID_PCM_S16LE) {
+ sc->media_type = ff_codec_get_tag(gxf_media_types, st->codecpar->codec_id);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE) {
av_log(s, AV_LOG_ERROR, "only 16 BIT PCM LE allowed for now\n");
return -1;
}
- if (st->codec->sample_rate != 48000) {
+ if (st->codecpar->sample_rate != 48000) {
av_log(s, AV_LOG_ERROR, "only 48000hz sampling rate is allowed\n");
return -1;
}
- if (st->codec->channels != 1) {
+ if (st->codecpar->channels != 1) {
av_log(s, AV_LOG_ERROR, "only mono tracks are allowed\n");
return -1;
}
sc->track_type = 2;
- sc->sample_rate = st->codec->sample_rate;
+ sc->sample_rate = st->codecpar->sample_rate;
avpriv_set_pts_info(st, 64, 1, sc->sample_rate);
sc->sample_size = 16;
sc->frame_rate_index = -2;
@@ -746,18 +746,18 @@ static int gxf_write_header(AVFormatContext *s)
gxf->audio_tracks++;
gxf->flags |= 0x04000000; /* audio is 16 bit pcm */
media_info = 'A';
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (i != 0) {
av_log(s, AV_LOG_ERROR, "video stream must be the first track\n");
return -1;
}
/* FIXME check from time_base ? */
- if (st->codec->height == 480 || st->codec->height == 512) { /* NTSC or NTSC+VBI */
+ if (st->codecpar->height == 480 || st->codecpar->height == 512) { /* NTSC or NTSC+VBI */
sc->frame_rate_index = 5;
sc->sample_rate = 60;
gxf->flags |= 0x00000080;
gxf->time_base = (AVRational){ 1001, 60000 };
- } else if (st->codec->height == 576 || st->codec->height == 608) { /* PAL or PAL+VBI */
+ } else if (st->codecpar->height == 576 || st->codecpar->height == 608) { /* PAL or PAL+VBI */
sc->frame_rate_index = 6;
sc->media_type++;
sc->sample_rate = 50;
@@ -773,12 +773,12 @@ static int gxf_write_header(AVFormatContext *s)
avpriv_set_pts_info(st, 64, gxf->time_base.num, gxf->time_base.den);
if (gxf_find_lines_index(st) < 0)
sc->lines_index = -1;
- sc->sample_size = st->codec->bit_rate;
+ sc->sample_size = st->codecpar->bit_rate;
sc->fields = 2; /* interlaced */
vsc = sc;
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MJPEG:
sc->track_type = 1;
gxf->flags |= 0x00004000;
@@ -797,7 +797,7 @@ static int gxf_write_header(AVFormatContext *s)
media_info = 'M';
break;
case AV_CODEC_ID_DVVIDEO:
- if (st->codec->pix_fmt == AV_PIX_FMT_YUV422P) {
+ if (st->codecpar->format == AV_PIX_FMT_YUV422P) {
sc->media_type += 2;
sc->track_type = 6;
gxf->flags |= 0x00002000;
@@ -903,7 +903,7 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
/* If the video is frame-encoded, the frame numbers shall be represented by
* even field numbers.
* see SMPTE360M-2004 6.4.2.1.3 Media field number */
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
field_nb = gxf->nb_fields;
} else {
field_nb = av_rescale_rnd(pkt->dts, gxf->time_base.den,
@@ -913,10 +913,10 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
avio_w8(pb, sc->media_type);
avio_w8(pb, st->index);
avio_wb32(pb, field_nb);
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
avio_wb16(pb, 0);
avio_wb16(pb, size / 2);
- } else if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
int frame_type = gxf_parse_mpeg_frame(sc, pkt->data, pkt->size);
if (frame_type == AV_PICTURE_TYPE_I) {
avio_w8(pb, 0x0d);
@@ -929,7 +929,7 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
sc->pframes++;
}
avio_wb24(pb, size);
- } else if (st->codec->codec_id == AV_CODEC_ID_DVVIDEO) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO) {
avio_w8(pb, size / 4096);
avio_wb24(pb, 0);
} else
@@ -951,15 +951,15 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
gxf_write_packet_header(pb, PKT_MEDIA);
- if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
padding = 4 - pkt->size % 4;
- else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
gxf_write_media_preamble(s, pkt, pkt->size + padding);
avio_write(pb, pkt->data, pkt->size);
gxf_write_padding(pb, padding);
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!(gxf->flt_entries_nb % 500)) {
int err;
if ((err = av_reallocp_array(&gxf->flt_entries,
@@ -997,7 +997,7 @@ static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cu
for (i = 0; i < 2; i++) {
AVStream *st = s->streams[pkt[i]->stream_index];
sc[i] = st->priv_data;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
field_nb[i] = av_rescale_rnd(pkt[i]->dts, gxf->time_base.den,
(int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
field_nb[i] &= ~1; // compare against even field number because audio must be before video
@@ -1011,7 +1011,7 @@ static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cu
static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
{
- if (pkt && s->streams[pkt->stream_index]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (pkt && s->streams[pkt->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
pkt->duration = 2; // enforce 2 fields
return ff_audio_rechunk_interleave(s, out, pkt, flush,
ff_interleave_packet_per_dts, gxf_compare_field_nb);