Skip to content

Commit e97cbbd

Browse files
constexpr and PR comments
Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
1 parent e8f846a commit e97cbbd

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <math.h>
2525
#include <algorithm>
2626
#include <array>
27+
#include <string_view>
2728
#include <stdlib.h>
2829
#include <stl_ext/stl_ext_algo.h>
2930
#include <stl_ext/string_algo.h>
@@ -70,7 +71,6 @@ namespace TwkMovie
7071
#define FPS_PRECISION_LIMIT 1000 // 5 sig figs
7172
#define RV_OUTPUT_VIDEO_CODEC "mjpeg"
7273
#define RV_OUTPUT_AUDIO_CODEC "pcm_s16be"
73-
#define RV_SEEK_FRAME_OFFSET 1
7474

7575
#if 0
7676
#define DB_LOG_LEVEL AV_LOG_ERROR
@@ -620,6 +620,7 @@ namespace TwkMovie
620620

621621
namespace
622622
{
623+
constexpr int rv_seek_frame_offset = 1;
623624

624625
//----------------------------------------------------------------------
625626
//
@@ -632,18 +633,16 @@ namespace TwkMovie
632633
// actually support. But just in case ....
633634
//
634635

635-
const char* slowRandomAccessCodecsArray[] = {
636-
"3iv2", "3ivd", "ap41", "avc1",
637-
"div1", "div2", "div3", "div4",
638-
"div5", "div6", "divx", "dnxhd",
639-
"dx50", "h263", "h264", "i263",
640-
"iv31", "iv32", "m4s2", "mp42",
641-
"mp43", "mp4s", "mp4v", "mpeg4",
642-
"mpg1", "mpg3", "mpg4", "pim1",
643-
"png", "s263", "svq1", "svq3",
644-
"u263", "vc1", "vc1_vdpau", "vc1image",
645-
"viv1", "wmv3", "wmv3_vdpau", "wmv3image",
646-
"xith", "xvid", "libdav1d", 0};
636+
constexpr std::array<std::string_view, 44> slowRandomAccessCodecs = {
637+
"3iv2", "3ivd", "ap41", "avc1", "div1",
638+
"div2", "div3", "div4", "div5", "div6",
639+
"divx", "dnxhd", "dx50", "h263", "h264",
640+
"i263", "iv31", "iv32", "m4s2", "mp42",
641+
"mp43", "mp4s", "mp4v", "mpeg4", "mpg1",
642+
"mpg3", "mpg4", "pim1", "png", "s263",
643+
"svq1", "svq3", "u263", "vc1", "vc1_vdpau",
644+
"vc1image", "viv1", "wmv3", "wmv3_vdpau", "wmv3image",
645+
"xith", "xvid", "libdav1d", nullptr};
647646

648647
const char* supportedEncodingCodecsArray[] = {
649648
"dvvideo", "libx264", "mjpeg", "pcm_s16be", "rawvideo", 0};
@@ -723,15 +722,17 @@ namespace TwkMovie
723722
bool codecHasSlowAccess(string name)
724723
{
725724
boost::algorithm::to_lower(name);
726-
for (const char** p = slowRandomAccessCodecsArray; *p; p++)
725+
for (const std::string_view& codec : slowRandomAccessCodecs)
727726
{
728-
if (*p == name)
727+
std::cout << "Comparing " << codec << " with " << name
728+
<< std::endl;
729+
if (codec == name)
729730
{
730731
return true;
731732
}
732733
}
733734
return false;
734-
};
735+
}
735736

736737
bool isMP4format(AVFormatContext* avFormatContext)
737738
{
@@ -3321,7 +3322,7 @@ namespace TwkMovie
33213322
// for now. Note: FFmpeg internally seeks with the dts timestamp and not
33223323
// the pts timestamp. We need to have a bit of a buffer.
33233324
const int64_t seekTarget =
3324-
int64_t((inframe - RV_SEEK_FRAME_OFFSET) * frameDur);
3325+
int64_t((inframe - rv_seek_frame_offset) * frameDur);
33253326

33263327
DBL(DB_VIDEO, "seekTarget: " << seekTarget
33273328
<< " last: " << track->lastDecodedVideo
@@ -3450,7 +3451,7 @@ namespace TwkMovie
34503451
{
34513452
// The goal timestamp is the same as the seek target adjusted
34523453
// for pts vs dts.
3453-
const int64_t goalTS = (inframe - RV_SEEK_FRAME_OFFSET) * frameDur;
3454+
const int64_t goalTS = (inframe - rv_seek_frame_offset) * frameDur;
34543455

34553456
// If it is the first time we try to decode the stream, we need
34563457
// to start by reading a packet.

0 commit comments

Comments
 (0)