mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2026-04-24 23:13:37 +02:00
2014-10-25 Fred Gleason <fredg@paravelsystems.com>
* Implemented '--set-marker-end-*=' and '--set-marker-start-*=' options for rdimport(1) in 'utils/rdimport/markerset.cpp',, 'utils/rdimport/markerset.h', 'utils/rdimport/rdimport.cpp' and 'utils/rdimport/rdimport.h'.
This commit is contained in:
143
utils/rdimport/markerset.cpp
Normal file
143
utils/rdimport/markerset.cpp
Normal file
@@ -0,0 +1,143 @@
|
||||
// markerset.cpp
|
||||
//
|
||||
// Abstract a set of marker parameters.
|
||||
//
|
||||
// (C) Copyright 2014 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "markerset.h"
|
||||
|
||||
MarkerSet::MarkerSet()
|
||||
{
|
||||
marker_start_valid=false;
|
||||
marker_start_value=0;
|
||||
marker_end_valid=false;
|
||||
marker_end_value=0;
|
||||
marker_audio_length=0;
|
||||
}
|
||||
|
||||
|
||||
bool MarkerSet::hasStartValue() const
|
||||
{
|
||||
return marker_start_valid;
|
||||
}
|
||||
|
||||
|
||||
int MarkerSet::startValue(int lo_limit,int hi_limit) const
|
||||
{
|
||||
return LimitCheck(marker_start_value,lo_limit,hi_limit);
|
||||
}
|
||||
|
||||
|
||||
bool MarkerSet::hasEndValue() const
|
||||
{
|
||||
return marker_end_valid;
|
||||
}
|
||||
|
||||
|
||||
int MarkerSet::endValue(int lo_limit,int hi_limit) const
|
||||
{
|
||||
return LimitCheck(marker_end_value,lo_limit,hi_limit);
|
||||
}
|
||||
|
||||
|
||||
void MarkerSet::load(RDCmdSwitch *cmd,const QString &marker)
|
||||
{
|
||||
QString start_key="--set-marker-start-"+marker;
|
||||
QString end_key="--set-marker-end-"+marker;
|
||||
marker_marker=marker;
|
||||
for(unsigned i=0;i<cmd->keys();i++) {
|
||||
if(cmd->key(i)==start_key) {
|
||||
marker_start_value=cmd->value(i).toInt(&marker_start_valid);
|
||||
if(!marker_start_valid) {
|
||||
fprintf(stderr,"rdimport: invalid argment to %s\n",
|
||||
(const char *)start_key);
|
||||
exit(255);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)==end_key) {
|
||||
marker_end_value=cmd->value(i).toInt(&marker_end_valid);
|
||||
if(!marker_end_valid) {
|
||||
fprintf(stderr,"rdimport: invalid argment to %s\n",
|
||||
(const char *)end_key);
|
||||
exit(255);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
}
|
||||
if(marker_end_valid&&(!marker_start_valid)) {
|
||||
marker_start_value=0;
|
||||
marker_start_valid=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MarkerSet::setAudioLength(int msecs)
|
||||
{
|
||||
if(marker_start_valid&&(!marker_end_valid)) {
|
||||
marker_end_value=msecs;
|
||||
marker_end_valid=true;
|
||||
}
|
||||
marker_audio_length=msecs;
|
||||
}
|
||||
|
||||
|
||||
void MarkerSet::dump()
|
||||
{
|
||||
if(marker_start_valid) {
|
||||
printf(" Marker Start %s: ",(const char *)marker_marker);
|
||||
printf("%d mS\n",marker_start_value);
|
||||
}
|
||||
if(marker_end_valid) {
|
||||
printf(" Marker End %s: ",(const char *)marker_marker);
|
||||
printf("%d mS\n",marker_end_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int MarkerSet::LimitCheck(int value,int lo_limit,int hi_limit) const
|
||||
{
|
||||
if(lo_limit!=-1) {
|
||||
if(value<lo_limit) {
|
||||
return lo_limit;
|
||||
}
|
||||
}
|
||||
if(hi_limit!=-1) {
|
||||
if(value>hi_limit) {
|
||||
return hi_limit;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int MarkerSet::FrontReference(int value) const
|
||||
{
|
||||
if(value>=0) {
|
||||
if(value>marker_audio_length) {
|
||||
return marker_audio_length;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if((marker_audio_length+value)<0) {
|
||||
return 0;
|
||||
}
|
||||
return marker_audio_length+value;
|
||||
}
|
||||
Reference in New Issue
Block a user