From: John F. <jo...@us...> - 2013-04-29 14:43:27
|
Update of /cvsroot/ingex/ingex/common In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16601/common Modified Files: Makefile Timecode.cpp Timecode.h timecode_test.cpp unittests.cpp video_burn_in_timecode.cpp Log Message: Refactoring of Timecode class Index: Makefile =================================================================== RCS file: /cvsroot/ingex/ingex/common/Makefile,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Makefile 12 Apr 2013 10:41:00 -0000 1.15 --- Makefile 29 Apr 2013 14:43:25 -0000 1.16 *************** *** 4,8 **** # Makefile for building common functions # ! # Copyright (C) 2005 - 2010 British Broadcasting Corporation # # This program is free software; you can redistribute it and/or --- 4,8 ---- # Makefile for building common functions # ! # Copyright (C) 2013 British Broadcasting Corporation # # This program is free software; you can redistribute it and/or *************** *** 22,30 **** # ! CC=gcc ! OPT=-DNDEBUG -O3 -mmmx -msse2 INCLUDES= ! CFLAGS=-Wall -W -Wno-unused-parameter -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE $(OPT) $(INCLUDES) ! CXXFLAGS=-Wall -W -Wno-unused-parameter -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE $(OPT) $(INCLUDES) # Check for old-style FFMPEG header locations and if needed add -DFFMPEG_OLD_INCLUDE_PATHS --- 22,49 ---- # ! SED = sed ! MV = mv ! CC = gcc ! OPT = -DNDEBUG -O3 -mmmx -msse2 INCLUDES= ! CFLAGS = -Wall -Wextra -Werror -Wno-unused-parameter -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE $(OPT) $(INCLUDES) ! CXXFLAGS = -Wall -Wextra -Werror -Wno-unused-parameter -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE $(OPT) $(INCLUDES) ! ! # $(call make-depend,source-file,object-file,depend-file) ! define make-depend-cc ! $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -MM $1 -MP -MT $2 -MF $3 ! endef ! ! define make-depend-cxx ! $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -MM $1 -MP -MT $2 -MF $3 ! endef ! ! %.o: %.c ! $(call make-depend-cc,$<,$@,$(subst .o,.d,$@)) ! $(COMPILE.c) -o $@ $< ! ! %.o: %.cpp ! $(call make-depend-cxx,$<,$@,$(subst .o,.d,$@)) ! $(COMPILE.cpp) -o $@ $< # Check for old-style FFMPEG header locations and if needed add -DFFMPEG_OLD_INCLUDE_PATHS *************** *** 35,39 **** endif ! PROGS = unittests timecode_test LIBCOMMON = libcommon.a --- 54,58 ---- endif ! PROGS = unittests timecode_test newtimecode_test LIBCOMMON = libcommon.a *************** *** 41,45 **** CPPFILES=$(wildcard *.cpp) ! OBJECTS=$(CFILES:%.c=%.o) $(CPPFILES:%.cpp=%.o) PROGOBJECTS = $(PROGS:%=%.o) LIBOBJECTS = $(filter-out $(PROGOBJECTS), $(OBJECTS)) --- 60,65 ---- CPPFILES=$(wildcard *.cpp) ! OBJECTS = $(CFILES:%.c=%.o) $(CPPFILES:%.cpp=%.o) ! DEPENDENCIES = $(CFILES:%.c=%.d) $(CPPFILES:%.cpp=%.d) PROGOBJECTS = $(PROGS:%=%.o) LIBOBJECTS = $(filter-out $(PROGOBJECTS), $(OBJECTS)) *************** *** 59,62 **** --- 79,85 ---- $(LINK.o) -o $@ $^ -lstdc++ + newtimecode_test: newtimecode_test.o $(LIBCOMMON) + $(LINK.o) -o $@ $^ -lstdc++ + .PHONY: check check: all *************** *** 76,77 **** --- 99,104 ---- cd tools && $(MAKE) + ifneq ($(MAKECMDGOALS),clean) + -include $(DEPENDENCIES) + endif + Index: Timecode.cpp =================================================================== RCS file: /cvsroot/ingex/ingex/common/Timecode.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Timecode.cpp 12 Apr 2013 10:41:00 -0000 1.18 --- Timecode.cpp 29 Apr 2013 14:43:25 -0000 1.19 *************** *** 4,8 **** * Class to hold a Timecode * ! * Copyright (C) 2006 - 2010 British Broadcasting Corporation. * All Rights Reserved. * --- 4,8 ---- * Class to hold a Timecode * ! * Copyright (C) 2013 British Broadcasting Corporation. * All Rights Reserved. [...1309 lines suppressed...] /** *************** *** 843,851 **** Timecode operator+(const Timecode & lhs, const unsigned int & frames) { ! return Timecode(lhs.mFramesSinceMidnight + frames, lhs.mFormat); } } // namespace - - --- 527,533 ---- Timecode operator+(const Timecode & lhs, const unsigned int & frames) { ! return Timecode(lhs.mFrameCount + frames, lhs.mFormat); } } // namespace Index: Timecode.h =================================================================== RCS file: /cvsroot/ingex/ingex/common/Timecode.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Timecode.h 12 Apr 2013 10:41:00 -0000 1.11 --- Timecode.h 29 Apr 2013 14:43:25 -0000 1.12 *************** *** 4,8 **** * Class to hold a Timecode * ! * Copyright (C) 2006 - 2010 British Broadcasting Corporation. * All Rights Reserved. * --- 4,8 ---- * Class to hold a Timecode * ! * Copyright (C) 2013 British Broadcasting Corporation. * All Rights Reserved. * *************** *** 26,29 **** --- 26,32 ---- #define Timecode_h + #include "Rational.h" + #include <string> + namespace Ingex { *************** *** 32,58 **** { public: ! // supported timecode formats ! enum FormatEnumType { ! NONE, ! TC_23NDF, ! TC_24, ! TC_25, ! TC_29DF, ! TC_29NDF, ! TC_30, ! TC_50, ! TC_59DF, ! TC_59NDF, ! TC_60 }; // constructors Timecode(); ! Timecode(unsigned int frames_since_midnight, unsigned int fps_num, unsigned int fps_den, bool df); ! Timecode(unsigned int frames_since_midnight, FormatEnumType format); ! Timecode(unsigned int hr, unsigned int min, unsigned int sec, unsigned int frame, unsigned int frame_of_pair, unsigned int fps_num, unsigned int fps_den, bool df); ! Timecode(unsigned int hr, unsigned int min, unsigned int sec, unsigned int frame, unsigned int frame_of_pair, FormatEnumType format); ! Timecode(const char * s, unsigned int fps_num, unsigned int fps_den, bool df); ! Timecode(const char * s, FormatEnumType format); // copy constructor Timecode(const Timecode & tc); --- 35,77 ---- { public: ! class Format { ! public: ! enum FormatEnumType ! { ! TC_NONE, ! TC_23NDF, ! TC_24, ! TC_25, ! TC_29DF, ! TC_29NDF, ! TC_30, ! TC_50, ! TC_59DF, ! TC_59NDF, ! TC_60 ! }; ! static Format GetFormat(unsigned int fps_num, unsigned int fps_den, bool df); ! Format(); ! Format(FormatEnumType format, std::string name, Ingex::Rational rate, unsigned int nominal_rate, bool drop_frame); ! FormatEnumType EnumValue() const { return mFormat; } ! std::string Name() const { return mName; } ! Ingex::Rational Rate() const { return mRate; } ! unsigned int NominalRate() const { return mNominalRate; } ! bool DropFrame() const { return mDropFrame; } ! private: ! // members ! FormatEnumType mFormat; ! std::string mName; ! Ingex::Rational mRate; ! unsigned int mNominalRate; ! bool mDropFrame; }; + // constructors Timecode(); ! Timecode(uint64_t frames_since_epoch, Timecode::Format format); ! Timecode(unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int frames, unsigned int frame_of_pair, Timecode::Format format); ! Timecode(const std::string & s, Timecode::Format format); // copy constructor Timecode(const Timecode & tc); *************** *** 60,89 **** Timecode & operator=(const Timecode &); - // static methods - static FormatEnumType GetFormat(unsigned int fps_num, unsigned int fps_den, bool df); - static bool UsingEG40(); // methods ! const char * Text() const; ! const char * TextNoSeparators() const; ! unsigned int FramesSinceMidnight() const { return mFramesSinceMidnight; } ! unsigned int FrameRateNumerator() const; ! unsigned int FrameRateDenominator() const; ! bool DropFrame() const; ! unsigned int Hours() const { return mHours; } ! unsigned int Minutes() const { return mMinutes; } ! unsigned int Seconds() const { return mSeconds; } ! unsigned int Frames() const { return mFrames; } ! unsigned int FrameOfPair() const { return mFrameOfPair; } unsigned int ColorFrame() const; - bool IsNull() const { return NONE == mFormat; } unsigned int NominalFps(); ! FormatEnumType Format() const; ! const char * FormatName() const; void Jam(unsigned int hours, unsigned int minutes, bool color_frame_id, unsigned int color_frame); // operator overload friend Timecode operator+(const Timecode & lhs, const unsigned int & frames); - friend unsigned int operator-(const Timecode & lhs, const Timecode & rhs); void operator+=(unsigned int frames); void operator+=(int frames); --- 79,104 ---- Timecode & operator=(const Timecode &); // methods ! bool IsNull() const { return Format::TC_NONE == mFormat.EnumValue(); } ! std::string Text() const; ! std::string TextNoSeparators() const; ! unsigned int FrameCount() const { return mFrameCount; } ! unsigned int FrameRateNumerator() const { return mFormat.Rate().numerator; } ! unsigned int FrameRateDenominator() const { return mFormat.Rate().denominator; } ! bool DropFrame() const { return mFormat.DropFrame(); } ! //unsigned int Hours() const; ! //unsigned int Minutes() const; ! //unsigned int Seconds() const; ! //unsigned int Frames() const; ! //unsigned int FrameOfPair(); unsigned int ColorFrame() const; unsigned int NominalFps(); ! std::string FormatName() const { return mFormat.Name(); } void Jam(unsigned int hours, unsigned int minutes, bool color_frame_id, unsigned int color_frame); + void GetHoursMinsEtc(unsigned int & hours, unsigned int & minutes, unsigned int & seconds, unsigned int & frames, unsigned int & frame_of_pair) const; // operator overload friend Timecode operator+(const Timecode & lhs, const unsigned int & frames); void operator+=(unsigned int frames); void operator+=(int frames); *************** *** 91,113 **** private: ! // fundamental data ! FormatEnumType mFormat; ! unsigned int mFramesSinceMidnight; ! ! // derived data ! unsigned int mHours; ! unsigned int mMinutes; ! unsigned int mSeconds; ! unsigned int mFrames; ! unsigned int mFrameOfPair; ! mutable char mText[16]; ! mutable char mTextNoSeparators[16]; ! // methods ! void UpdateFramesSinceMidnight(); ! void UpdateHoursMinsEtc(); ! void CheckFramesSinceMidnight(); }; } // namespace --- 106,129 ---- private: ! // data ! Format mFormat; ! unsigned int mFrameCount; // methods ! void Set(unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int frames, unsigned int frame_of_pair); }; + const Timecode::Format TC_FORMAT_NONE(Ingex::Timecode::Format::TC_NONE, "null", Ingex::Rational (0, 0), 0, false); + const Timecode::Format TC_FORMAT_23NDF(Ingex::Timecode::Format::TC_23NDF, "23.98 fps non-drop", Ingex::Rational (24, 1), 24, false); + const Timecode::Format TC_FORMAT_24(Ingex::Timecode::Format::TC_24, "24 fps", Ingex::Rational (24, 1), 24, false); + const Timecode::Format TC_FORMAT_25(Ingex::Timecode::Format::TC_25, "25 fps", Ingex::Rational (25, 1), 25, false); + const Timecode::Format TC_FORMAT_29NDF(Ingex::Timecode::Format::TC_29NDF, "29.97 fps non-drop-frame", Ingex::Rational (30000, 1001), 30, false); + const Timecode::Format TC_FORMAT_29DF(Ingex::Timecode::Format::TC_29DF, "29.97 fps drop-frame", Ingex::Rational (30000, 1001), 30, true); + const Timecode::Format TC_FORMAT_30(Ingex::Timecode::Format::TC_30, "30 fps", Ingex::Rational (30, 1), 30, false); + const Timecode::Format TC_FORMAT_50(Ingex::Timecode::Format::TC_50, "50 fps", Ingex::Rational (50, 1), 50, false); + const Timecode::Format TC_FORMAT_59NDF(Ingex::Timecode::Format::TC_59NDF, "59.94 fps non-drop-frame", Ingex::Rational (60000, 1001), 60, false); + const Timecode::Format TC_FORMAT_59DF(Ingex::Timecode::Format::TC_59DF, "59.94 fps drop-frame", Ingex::Rational (60000, 1001), 60, true); + const Timecode::Format TC_FORMAT_60(Ingex::Timecode::Format::TC_60, "60 fps", Ingex::Rational (60, 1), 60, false); + + } // namespace Index: video_burn_in_timecode.cpp =================================================================== RCS file: /cvsroot/ingex/ingex/common/video_burn_in_timecode.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** video_burn_in_timecode.cpp 14 Oct 2011 09:41:36 -0000 1.2 --- video_burn_in_timecode.cpp 29 Apr 2013 14:43:25 -0000 1.3 *************** *** 382,394 **** // timecode is always HH:MM:SS:FF giving a mask 20+20+13+20+20+13+20+20+13+20+20 = 199 // by 24 pixels high ! setup_tc_digit(0, timecode.Hours() / 10, tc_mask); ! setup_tc_digit(20, timecode.Hours() % 10, tc_mask); setup_colon(20+20+2, tc_mask); ! setup_tc_digit(53, timecode.Minutes() / 10, tc_mask); ! setup_tc_digit(73, timecode.Minutes() % 10, tc_mask); setup_colon(20+20+13+20+20+2, tc_mask); ! setup_tc_digit(106, timecode.Seconds() / 10, tc_mask); ! setup_tc_digit(126, timecode.Seconds() % 10, tc_mask); if (timecode.DropFrame()) { --- 382,396 ---- // timecode is always HH:MM:SS:FF giving a mask 20+20+13+20+20+13+20+20+13+20+20 = 199 // by 24 pixels high + unsigned int hours, minutes, seconds, frames, frame_of_pair; + timecode.GetHoursMinsEtc(hours, minutes, seconds, frames, frame_of_pair); ! setup_tc_digit(0, hours / 10, tc_mask); ! setup_tc_digit(20, hours % 10, tc_mask); setup_colon(20+20+2, tc_mask); ! setup_tc_digit(53, minutes / 10, tc_mask); ! setup_tc_digit(73, minutes % 10, tc_mask); setup_colon(20+20+13+20+20+2, tc_mask); ! setup_tc_digit(106, seconds / 10, tc_mask); ! setup_tc_digit(126, seconds % 10, tc_mask); if (timecode.DropFrame()) { *************** *** 399,404 **** setup_colon(20+20+13+20+20+13+20+20+2, tc_mask); } ! setup_tc_digit(159, timecode.Frames() / 10, tc_mask); ! setup_tc_digit(179, timecode.Frames() % 10, tc_mask); } --- 401,406 ---- setup_colon(20+20+13+20+20+13+20+20+2, tc_mask); } ! setup_tc_digit(159, frames / 10, tc_mask); ! setup_tc_digit(179, frames % 10, tc_mask); } Index: timecode_test.cpp =================================================================== RCS file: /cvsroot/ingex/ingex/common/timecode_test.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** timecode_test.cpp 12 Apr 2013 10:41:00 -0000 1.2 --- timecode_test.cpp 29 Apr 2013 14:43:25 -0000 1.3 *************** *** 232,236 **** // Initialise time address to jam time ! Ingex::Timecode tc(0, 0, 0, 0, 0, Ingex::Timecode::TC_29DF); tc.Jam(jam_hh, jam_mm, color_frame_id, frames_since_epoch % 2); --- 232,236 ---- // Initialise time address to jam time ! Ingex::Timecode tc(0, 0, 0, 0, 0, Ingex::TC_FORMAT_29DF); tc.Jam(jam_hh, jam_mm, color_frame_id, frames_since_epoch % 2); *************** *** 265,269 **** //int utc_offset = UtcOffsetTable::Instance()->OffsetByTai(tai_time_x30000 / 30000); //printf("%s %2d %5d/%5d %s\n", ts, utc_offset, utc_time_fraction, 30000, tc.Text()); ! printf("%s %5d/%5d %s %s\n", ts, utc_time_fraction, 30000, tzs, tc.Text()); } --- 265,269 ---- //int utc_offset = UtcOffsetTable::Instance()->OffsetByTai(tai_time_x30000 / 30000); //printf("%s %2d %5d/%5d %s\n", ts, utc_offset, utc_time_fraction, 30000, tc.Text()); ! printf("%s %5d/%5d %s %s\n", ts, utc_time_fraction, 30000, tzs, tc.Text().c_str()); } Index: unittests.cpp =================================================================== RCS file: /cvsroot/ingex/ingex/common/unittests.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** unittests.cpp 27 Sep 2011 10:18:30 -0000 1.3 --- unittests.cpp 29 Apr 2013 14:43:25 -0000 1.4 *************** *** 77,81 **** // colourbars and timecode burning ! Ingex::Timecode timecode(12, 34, 45, 00, 0, 25, 1, false); uyvy_color_bars(width, height, 1, frame); --- 77,81 ---- // colourbars and timecode burning ! Ingex::Timecode timecode(12, 34, 45, 00, 0, Ingex::TC_FORMAT_25); uyvy_color_bars(width, height, 1, frame); |