]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/dv.c
rtpdec_vp9: Update header parsing to spec draft 02
[ffmpeg] / libavformat / dv.c
index d7d62f19914b480438fe7e6408f65a8e8ebcaebc..f7df279bdc0a262112c58c1867ebe75527c30597 100644 (file)
@@ -39,7 +39,7 @@
 #include "dv.h"
 
 struct DVDemuxContext {
-    const DVprofile*  sys;    /* Current DV profile. E.g.: 525/60, 625/50 */
+    const AVDVProfile*  sys;    /* Current DV profile. E.g.: 525/60, 625/50 */
     AVFormatContext*  fctx;
     AVStream*         vst;
     AVStream*         ast[4];
@@ -109,7 +109,7 @@ static const int dv_audio_frequency[3] = {
  *    are converted into 16bit linear ones.
  */
 static int dv_extract_audio(uint8_t *frame, uint8_t **ppcm,
-                            const DVprofile *sys)
+                            const AVDVProfile *sys)
 {
     int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
     uint16_t lc, rc;
@@ -245,8 +245,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, uint8_t *frame)
             if (!c->ast[i])
                 break;
             avpriv_set_pts_info(c->ast[i], 64, 1, 30000);
-            c->ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-            c->ast[i]->codec->codec_id   = AV_CODEC_ID_PCM_S16LE;
+            c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+            c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
 
             av_init_packet(&c->audio_pkt[i]);
             c->audio_pkt[i].size         = 0;
@@ -254,10 +254,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, uint8_t *frame)
             c->audio_pkt[i].stream_index = c->ast[i]->index;
             c->audio_pkt[i].flags       |= AV_PKT_FLAG_KEY;
         }
-        c->ast[i]->codec->sample_rate    = dv_audio_frequency[freq];
-        c->ast[i]->codec->channels       = 2;
-        c->ast[i]->codec->channel_layout = AV_CH_LAYOUT_STEREO;
-        c->ast[i]->codec->bit_rate       = 2 * dv_audio_frequency[freq] * 16;
+        c->ast[i]->codecpar->sample_rate    = dv_audio_frequency[freq];
+        c->ast[i]->codecpar->channels       = 2;
+        c->ast[i]->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+        c->ast[i]->codecpar->bit_rate       = 2 * dv_audio_frequency[freq] * 16;
         c->ast[i]->start_time            = 0;
     }
     c->ach = i;
@@ -268,21 +268,20 @@ static int dv_extract_audio_info(DVDemuxContext *c, uint8_t *frame)
 static int dv_extract_video_info(DVDemuxContext *c, uint8_t *frame)
 {
     const uint8_t *vsc_pack;
-    AVCodecContext *avctx;
     int apt, is16_9;
     int size = 0;
 
     if (c->sys) {
-        avctx = c->vst->codec;
+        AVCodecParameters *par = c->vst->codecpar;
 
         avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
                             c->sys->time_base.den);
         c->vst->avg_frame_rate = av_inv_q(c->vst->time_base);
-        if (!avctx->width) {
-            avctx->width  = c->sys->width;
-            avctx->height = c->sys->height;
+        if (!par->width) {
+            par->width  = c->sys->width;
+            par->height = c->sys->height;
         }
-        avctx->pix_fmt = c->sys->pix_fmt;
+        par->format = c->sys->pix_fmt;
 
         /* finding out SAR is a little bit messy */
         vsc_pack = dv_extract_pack(frame, dv_video_control);
@@ -290,9 +289,9 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t *frame)
         is16_9   = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
                                  (!apt && (vsc_pack[2] & 0x07) == 0x07)));
         c->vst->sample_aspect_ratio = c->sys->sar[is16_9];
-        avctx->bit_rate = av_rescale_q(c->sys->frame_size,
-                                       (AVRational) { 8, 1 },
-                                       c->sys->time_base);
+        par->bit_rate = av_rescale_q(c->sys->frame_size,
+                                     (AVRational) { 8, 1 },
+                                     c->sys->time_base);
         size = c->sys->frame_size;
     }
     return size;
@@ -315,9 +314,9 @@ DVDemuxContext *avpriv_dv_init_demux(AVFormatContext *s)
     }
 
     c->fctx                   = s;
-    c->vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    c->vst->codec->codec_id   = AV_CODEC_ID_DVVIDEO;
-    c->vst->codec->bit_rate   = 25000000;
+    c->vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    c->vst->codecpar->codec_id   = AV_CODEC_ID_DVVIDEO;
+    c->vst->codecpar->bit_rate   = 25000000;
     c->vst->start_time        = 0;
 
     return c;
@@ -347,7 +346,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
     uint8_t *ppcm[5] = { 0 };
 
     if (buf_size < DV_PROFILE_BYTES ||
-        !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
+        !(c->sys = av_dv_frame_profile(c->sys, buf, buf_size)) ||
         buf_size < c->sys->frame_size) {
         return -1;   /* Broken frame, or not enough data */
     }
@@ -358,7 +357,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
     for (i = 0; i < c->ach; i++) {
         c->audio_pkt[i].size = size;
         c->audio_pkt[i].pts  = c->abytes * 30000 * 8 /
-                               c->ast[i]->codec->bit_rate;
+                               c->ast[i]->codecpar->bit_rate;
         ppcm[i] = c->audio_buf[i];
     }
     if (c->ach)
@@ -395,9 +394,10 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
                                int64_t timestamp, int flags)
 {
     // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
-    const DVprofile *sys = avpriv_dv_codec_profile(c->vst->codec);
+    const AVDVProfile *sys = av_dv_codec_profile(c->vst->codecpar->width, c->vst->codecpar->height,
+                                                 c->vst->codecpar->format);
     int64_t offset;
-    int64_t size       = avio_size(s->pb) - s->data_offset;
+    int64_t size       = avio_size(s->pb) - s->internal->data_offset;
     int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size;
 
     offset = sys->frame_size * timestamp;
@@ -407,7 +407,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
     else if (offset < 0)
         offset = 0;
 
-    return offset + s->data_offset;
+    return offset + s->internal->data_offset;
 }
 
 void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
@@ -415,7 +415,7 @@ void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
     c->frames = frame_offset;
     if (c->ach)
         c->abytes = av_rescale_q(c->frames, c->sys->time_base,
-                                 (AVRational) { 8, c->ast[0]->codec->bit_rate });
+                                 (AVRational) { 8, c->ast[0]->codecpar->bit_rate });
 
     c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
     c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
@@ -460,9 +460,9 @@ static int dv_read_header(AVFormatContext *s)
         avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
         return AVERROR(EIO);
 
-    c->dv_demux->sys = avpriv_dv_frame_profile(c->dv_demux->sys,
-                                               c->buf,
-                                               DV_PROFILE_BYTES);
+    c->dv_demux->sys = av_dv_frame_profile(c->dv_demux->sys,
+                                           c->buf,
+                                           DV_PROFILE_BYTES);
     if (!c->dv_demux->sys) {
         av_log(s, AV_LOG_ERROR,
                "Can't determine profile of DV input stream.\n");