Merge commit 'fcc455ff2e11ed04603aead1984a92ac3a4be226'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 6 Aug 2013 16:01:03 +0000 (18:01 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 6 Aug 2013 16:01:03 +0000 (18:01 +0200)
* commit 'fcc455ff2e11ed04603aead1984a92ac3a4be226':
  avformat/dv: K&R formatting cosmetics

Conflicts:
libavformat/dv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/dv.c

@@@ -83,17 -81,14 +83,17 @@@ static const uint8_t *dv_extract_pack(u
  
      switch (t) {
      case dv_audio_source:
-         offs = (80*6 + 80*16*3 + 3);
+         offs = (80 * 6 + 80 * 16 * 3 + 3);
          break;
      case dv_audio_control:
-         offs = (80*6 + 80*16*4 + 3);
+         offs = (80 * 6 + 80 * 16 * 4 + 3);
          break;
      case dv_video_control:
-         offs = (80*5 + 48 + 5);
+         offs = (80 * 5 + 48 + 5);
          break;
 +    case dv_timecode:
 +        offs = (80*1 + 3 + 3);
 +        break;
      default:
          return NULL;
      }
@@@ -279,7 -277,12 +288,7 @@@ static int dv_extract_video_info(DVDemu
  
          avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
                              c->sys->time_base.den);
-         avctx->time_base= c->sys->time_base;
+         avctx->time_base = c->sys->time_base;
 -        if (!avctx->width) {
 -            avctx->width  = c->sys->width;
 -            avctx->height = c->sys->height;
 -        }
 -        avctx->pix_fmt = c->sys->pix_fmt;
  
          /* finding out SAR is a little bit messy */
          vsc_pack = dv_extract_pack(frame, dv_video_control);
      return size;
  }
  
- /*
-  * The following 3 functions constitute our interface to the world
-  */
 +static int dv_extract_timecode(DVDemuxContext* c, uint8_t* frame, char *tc)
 +{
 +    const uint8_t *tc_pack;
 +
 +    // For PAL systems, drop frame bit is replaced by an arbitrary
 +    // bit so its value should not be considered. Drop frame timecode
 +    // is only relevant for NTSC systems.
 +    int prevent_df = c->sys->ltc_divisor == 25 || c->sys->ltc_divisor == 50;
 +
 +    tc_pack = dv_extract_pack(frame, dv_timecode);
 +    if (!tc_pack)
 +        return 0;
 +    av_timecode_make_smpte_tc_string(tc, AV_RB32(tc_pack + 1), prevent_df);
 +    return 1;
 +}
 +
+ /* The following 3 functions constitute our interface to the world */
  
- DVDemuxContextavpriv_dv_init_demux(AVFormatContext *s)
+ DVDemuxContext *avpriv_dv_init_demux(AVFormatContext *s)
  {
      DVDemuxContext *c;
  
@@@ -355,10 -341,10 +363,10 @@@ int avpriv_dv_get_packet(DVDemuxContex
  }
  
  int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
-                       uint8_t* buf, int buf_size, int64_t pos)
 -                             uint8_t *buf, int buf_size)
++                             uint8_t *buf, int buf_size, int64_t pos)
  {
      int size, i;
-     uint8_t *ppcm[4] = {0};
+     uint8_t *ppcm[4] = { 0 };
  
      if (buf_size < DV_PROFILE_BYTES ||
          !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
      /* FIXME: in case of no audio/bad audio we have to do something */
      size = dv_extract_audio_info(c, buf);
      for (i = 0; i < c->ach; i++) {
 +        c->audio_pkt[i].pos  = pos;
          c->audio_pkt[i].size = size;
-         c->audio_pkt[i].pts  = c->abytes * 30000 * 8 / c->ast[i]->codec->bit_rate;
+         c->audio_pkt[i].pts  = c->abytes * 30000 * 8 /
+                                c->ast[i]->codec->bit_rate;
          ppcm[i] = c->audio_buf[i];
      }
      if (c->ach)
@@@ -425,14 -412,11 +436,14 @@@ static int64_t dv_frame_offset(AVFormat
  
  void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
  {
-     c->frames= frame_offset;
+     c->frames = frame_offset;
 -    if (c->ach)
 +    if (c->ach) {
 +        if (c->sys) {
-         c->abytes= av_rescale_q(c->frames, c->sys->time_base,
-                                 (AVRational){8, c->ast[0]->codec->bit_rate});
-         }else
+         c->abytes = av_rescale_q(c->frames, c->sys->time_base,
+                                  (AVRational) { 8, c->ast[0]->codec->bit_rate });
 -
++        } else
 +            av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
 +    }
      c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
      c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
  }
@@@ -514,12 -469,10 +528,13 @@@ static int dv_read_header(AVFormatConte
          return -1;
      }
  
-     s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size, (AVRational){8,1},
+     s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size,
+                                (AVRational) { 8, 1 },
                                 c->dv_demux->sys->time_base);
  
 +    if (s->pb->seekable)
 +        dv_read_timecode(s);
 +
      return 0;
  }