[Ffmpeg-devel] Patch add function to read record time in dv video

Diego Biurrun diego
Sun Sep 4 15:40:05 CEST 2005


On Sat, Sep 03, 2005 at 02:58:52PM +0200, Diego Biurrun wrote:
> On Fri, Sep 02, 2005 at 11:35:42PM +0200, Michael Niedermayer wrote:
> > 
> > On Fri, Sep 02, 2005 at 11:23:48PM +0200, Diego Biurrun wrote:
> > > On Fri, Sep 02, 2005 at 11:55:41AM -0600, Fred Rothganger wrote:
> > > > 
> > > > --- dv.c	2 Sep 2005 08:30:26 -0000	1.45
> > > > +++ dv.c	2 Sep 2005 17:49:19 -0000
> > > > @@ -67,7 +67,7 @@
> > > > -     dv_viedo_recdate = 0x62,
> > > > +     dv_video_recdate = 0x62,
> > > > @@ -251,7 +251,7 @@
> > > > -    case dv_viedo_recdate:  /* VAUX recording date */
> > > > +    case dv_video_recdate:  /* VAUX recording date */
> > > 
> > > This is an unrelated fix for a stupid typo.
> > > 
> > > Michael, if you don't mind I'll commit this, OK?
> > 
> > ok, and please dont ask about such trivial things but instead just commit them
> 
> Applied and I won't bother you with these patches in the future.  Thanks
> for the confidence.

And here is the updated patch without the typo fix for review...

Diego
-------------- next part --------------
Index: dv.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/dv.h,v
retrieving revision 1.3
diff -u -r1.3 dv.h
--- dv.h	13 Oct 2004 00:03:00 -0000	1.3
+++ dv.h	2 Sep 2005 17:49:18 -0000
@@ -23,13 +23,21 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#ifndef FFMPEG_DV_H
+#define FFMPEG_DV_H
+
+#include <time.h>
+
 typedef struct DVDemuxContext DVDemuxContext;
 DVDemuxContext* dv_init_demux(AVFormatContext* s);
 int dv_get_packet(DVDemuxContext*, AVPacket *);
 int dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int);
 void dv_flush_audio_packets(DVDemuxContext*);
+int dv_extract_rectime(AVPacket*, struct tm*);
 
 typedef struct DVMuxContext DVMuxContext;
 DVMuxContext* dv_init_mux(AVFormatContext* s);
 int dv_assemble_frame(DVMuxContext *c, AVStream*, const uint8_t*, int, uint8_t**);
 void dv_delete_mux(DVMuxContext*);
+
+#endif
Index: dv.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/dv.c,v
retrieving revision 1.45
diff -u -r1.45 dv.c
--- dv.c	2 Sep 2005 08:30:26 -0000	1.45
+++ dv.c	2 Sep 2005 17:49:19 -0000
@@ -448,6 +448,12 @@
     case dv_video_control:
           offs = (80*5 + 48 + 5);
           break;
+    case dv_video_recdate:
+        offs = (80*5 + 48 + 10);
+        break;
+    case dv_video_rectime:
+        offs = (80*5 + 48 + 15);
+        break;
     default:
           return NULL;
     }   
@@ -611,6 +617,34 @@
     return size;
 }
 
+int dv_extract_rectime (AVPacket * pkt, struct tm * dt)
+{
+    const uint8_t * recdate = dv_extract_pack (pkt->data, dv_video_recdate);
+    const uint8_t * rectime = dv_extract_pack (pkt->data, dv_video_rectime);
+
+    if (recdate  &&  rectime)
+    {
+        dt->tm_isdst =   recdate[1] & 0x80;
+        dt->tm_mday  = ((recdate[2] & 0x30) >> 4) * 10 + (recdate[2] & 0xF);
+        dt->tm_mon   = ((recdate[3] & 0x10) >> 4) * 10 + (recdate[3] & 0xF);
+        dt->tm_year  = ((recdate[4] & 0xF0) >> 4) * 10 + (recdate[4] & 0xF);
+        if (dt->tm_year < 50)
+        {
+            dt->tm_year += 100;
+        }
+
+        dt->tm_sec  = ((rectime[2] & 0x70) >> 4) * 10 + (rectime[2] & 0xF);
+        dt->tm_min  = ((rectime[3] & 0x70) >> 4) * 10 + (rectime[3] & 0xF);
+        dt->tm_hour = ((rectime[4] & 0x30) >> 4) * 10 + (rectime[4] & 0xF);
+
+        return 0;
+    }
+    else
+    {
+        return AVERROR_INVALIDDATA;
+    }
+}
+
 /* 
  * The following 6 functions constitute our interface to the world
  */



More information about the ffmpeg-devel mailing list