summaryrefslogtreecommitdiff
path: root/command
diff options
context:
space:
mode:
Diffstat (limited to 'command')
-rw-r--r--command/markad-standalone.cpp2
-rw-r--r--command/streaminfo.cpp51
-rw-r--r--command/streaminfo.h10
3 files changed, 56 insertions, 7 deletions
diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp
index 079eaec..c247617 100644
--- a/command/markad-standalone.cpp
+++ b/command/markad-standalone.cpp
@@ -2307,7 +2307,7 @@ int usage(int svdrpport)
"-B --backupmarks\n"
" make a backup of existing marks\n"
"-G --genindex\n"
- " regenerate broken index file\n"
+ " regenerate index file\n"
"-I --saveinfo\n"
" correct information in info file\n"
"-L --extractlogo=<direction>[,width[,height]]\n"
diff --git a/command/streaminfo.cpp b/command/streaminfo.cpp
index 63ddde5..544c7d9 100644
--- a/command/streaminfo.cpp
+++ b/command/streaminfo.cpp
@@ -10,6 +10,16 @@
#include "streaminfo.h"
+cMarkAdStreamInfo::cMarkAdStreamInfo()
+{
+ Clear();
+}
+
+void cMarkAdStreamInfo::Clear()
+{
+ memset(&H264,0,sizeof(H264));
+}
+
bool cMarkAdStreamInfo::FindAC3AudioInfos(MarkAdContext *maContext, uchar *espkt, int eslen)
{
#pragma pack(1)
@@ -118,17 +128,49 @@ bool cMarkAdStreamInfo::FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt,
int nalu=pkt[4] & 0x1F;
+ maContext->Video.Info.Pict_Type=0;
if (nalu==NAL_AUD)
{
if (pkt[5]==0x10)
{
maContext->Video.Info.Pict_Type=MA_I_TYPE;
+ return true;
}
else
{
- maContext->Video.Info.Pict_Type=0;
+ if (maContext->Video.Info.Interlaced) {
+ if (H264.use_field) return true;
+ } else {
+ return true;
+ }
+ }
+ }
+
+ if ((nalu==NAL_SLICE) || (nalu==NAL_IDR_SLICE))
+ {
+ uint8_t *nal_data=(uint8_t*) alloca(len);
+ if (!nal_data) return false;
+ int nal_len = nalUnescape(nal_data, pkt + 5, len - 5);
+ cBitStream bs(nal_data, nal_len);
+
+ bs.skipUeGolomb(); // first_mb_in_slice
+ bs.skipUeGolomb(); // slice_type
+ bs.skipUeGolomb(); // pic_parameter_set_id
+ if (H264.separate_colour_plane_flag)
+ {
+ bs.skipBits(2); // colour_plane_id
+ }
+ bs.skipBits(H264.log2_max_frame_num); // frame_num
+
+ if (maContext->Video.Info.Interlaced)
+ {
+ if (bs.getBit()) // field_pic_flag
+ {
+ H264.use_field=bs.getBit(); // bottom_field_flag
+ } else {
+ H264.use_field=true;
+ }
}
- return true;
}
if (nalu==NAL_SPS)
@@ -156,7 +198,7 @@ bool cMarkAdStreamInfo::FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt,
(profile_idc==44) || (profile_idc==83) || (profile_idc==86))
{
if (bs.getUeGolomb() == 3) // chroma_format_idc
- bs.skipBit(); // separate_colour_plane_flag
+ H264.separate_colour_plane_flag=bs.getBit(); // separate_colour_plane_flag
bs.skipUeGolomb(); // bit_depth_luma_minus8
bs.skipUeGolomb(); // bit_depth_chroma_minus8
bs.skipBit(); // qpprime_y_zero_transform_bypass_flag
@@ -177,8 +219,7 @@ bool cMarkAdStreamInfo::FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt,
}
}
}
- // H264.log2_max_frame_num=bs.getUeGolomb()+4;
- bs.skipUeGolomb(); // log2_max_frame_num_minus4
+ H264.log2_max_frame_num=bs.getUeGolomb()+4; // log2_max_frame_num_minus4
int pic_order_cnt_type = bs.getUeGolomb(); // pic_order_cnt_type
if (pic_order_cnt_type == 0)
bs.skipUeGolomb(); // log2_max_pic_order_cnt_lsb_minus4
diff --git a/command/streaminfo.h b/command/streaminfo.h
index 92d15e4..177e44a 100644
--- a/command/streaminfo.h
+++ b/command/streaminfo.h
@@ -28,11 +28,19 @@ private:
NAL_AUX_SLICE = 0x19 // Auxilary Slice
};
+ struct H264
+ {
+ bool separate_colour_plane_flag;
+ int log2_max_frame_num;
+ bool use_field;
+ } H264;
+
int nalUnescape(uint8_t *dst, const uint8_t *src, int len);
bool FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt, int len);
bool FindH262VideoInfos(MarkAdContext *maContext, uchar *pkt, int len);
public:
- void Clear() {};
+ cMarkAdStreamInfo();
+ void Clear();
bool FindVideoInfos(MarkAdContext *maContext, uchar *pkt, int len);
bool FindAC3AudioInfos(MarkAdContext *maContext, uchar *espkt, int eslen);
};