frame->width = w;
frame->height = h;
- if (av_frame_get_buffer(frame, 32) < 0)
+ if (av_frame_get_buffer(frame, 32) < 0) {
+ av_frame_free(&frame);
return NULL;
+ }
return frame;
}
int i, j;
int w = 0, cw = 0, // in
pw = 0, cpw = 0; // prev
- int yuv, yuvu, yuvv;
int fil;
char metabuf[128];
unsigned int histy[DEPTH] = {0},
// Calculate luma histogram and difference with previous frame or field.
for (j = 0; j < link->h; j++) {
for (i = 0; i < link->w; i++) {
- yuv = in->data[0][w + i];
+ const int yuv = in->data[0][w + i];
histy[yuv]++;
- dify += abs(in->data[0][w + i] - prev->data[0][pw + i]);
+ dify += abs(yuv - prev->data[0][pw + i]);
}
w += in->linesize[0];
pw += prev->linesize[0];
// Calculate chroma histogram and difference with previous frame or field.
for (j = 0; j < s->chromah; j++) {
for (i = 0; i < s->chromaw; i++) {
- yuvu = in->data[1][cw+i];
- yuvv = in->data[2][cw+i];
+ const int yuvu = in->data[1][cw+i];
+ const int yuvv = in->data[2][cw+i];
histu[yuvu]++;
- difu += abs(in->data[1][cw+i] - prev->data[1][cpw+i]);
+ difu += abs(yuvu - prev->data[1][cpw+i]);
histv[yuvv]++;
- difv += abs(in->data[2][cw+i] - prev->data[2][cpw+i]);
+ difv += abs(yuvv - prev->data[2][cpw+i]);
histsat[p_sat[i]]++;
histhue[((int16_t*)p_hue)[i]]++;