...
 
Commits (3)
......@@ -91,6 +91,50 @@ double kvideo_fps(KObject* kobj)
}
KAZE_API
KObject* kvideo_frame_qp_table(KObject* video)
{
int stride;
int type;
int8_t* table;
assert(KOBJECT_VIDEO == kobject_type(video));
KVideo* kvid = to_kvideo(video);
table = av_frame_get_qp_table(kvid->pFrame,&stride,&type);
if (table) {
// convert this to a kimg
KObject* qtable = NULL;
KPixel val;
int x, y;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(kvid->pFrame->format);
int chroma_w = -((-kvid->pFrame->width) >> desc->log2_chroma_w);
int chroma_h = -((-kvid->pFrame->height) >> desc->log2_chroma_h);
int tablew = chroma_w << 3;
int tableh = chroma_h << 3;
qtable = kimage_new (char_px, 1, KDIMS(tablew, tableh));
for (y = 0; y < tableh; y++) {
for (x = 0; x < tablew; x++) {
val.int_px = table[y*stride + x];
kimage_set_pixel(qtable, val, 0, KCOORDS(x, y));
}
}
return qtable;
} else {
return NULL;
}
}
KAZE_API
KColorSpace kvideo_frame_color_type (KObject* kobj)
{
......
......@@ -124,6 +124,7 @@ cdef extern from "kvideo.h":
size_t kvideo_height (KObject* vid)
double kvideo_fps(KObject* kobj)
const char* kvideo_codec_name (KObject* kobj)
KObject* kvideo_frame_qp_table(KObject* video)
ctypedef enum KColorSpace:
FF_COLOR_NA
......
......@@ -601,6 +601,9 @@ cdef class Video:
def frame_to_image_decoded(self):
return _pythonize_kimage (kvideo_frame_to_kimage_decoded(self.kobj))
def frame_qp_table(self):
return _pythonize_kimage (kvideo_frame_qp_table(self.kobj))
def width(self):
return kvideo_width (self.kobj)
......@@ -663,36 +666,6 @@ cdef class Video:
def frame_pix_fmt_name(self):
return kvideo_frame_pix_fmt_name(self.kobj).decode()
def analyze_gop_structure(self):
#proceeds from current position to end of file, scanning the frame types
#if it sees a consistent pattern, then it returns that pattern (as string)
# else it returns 'variable'
gop = 'I'
gop_dict = {}
while not self.frame_next():
ftype = self.frame_type()
if ftype is 'I':
#if I frame, then beginning of gop
#if first I frame, ignore it
if gop == "I":
continue
if gop in gop_dict.keys():
gop_dict[gop] += 1
else:
gop_dict[gop] = 1
gop = 'I'
else:
gop += ftype
#this method will not count the very last gop, since it is likely
# to be cut off by the end of the video
#if there are more than 3 different gops present,
# then there's a variable gop
if len(gop_dict) > 3:
return 'variable'
else:
#otherwise, return a string of main gop
return max(gop_dict, key=gop_dict.get)
def __repr__ (self):
h = self.height()
......
......@@ -57,6 +57,10 @@ KErrorCode kvideo_frame_next_type (KObject* video, char ftype_target);
KAZE_API
int kvideo_frame_pixel_format (KObject* video);
KAZE_API
KObject* kvideo_frame_qp_table(KObject* video);
KAZE_API
const char* kvideo_frame_pix_fmt_name (KObject* kobj);
......