00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "global.h"
00016 #include <math.h>
00017
00018
00019
00020
00021
00022
00023
00024
00025 int rd_pic_decision(double snrY_version1, double snrY_version2, int bits_version1, int bits_version2, double lambda_picture)
00026 {
00027 double cost_version1, cost_version2;
00028
00029 cost_version1 = (double) bits_version1 * lambda_picture + snrY_version1;
00030 cost_version2 = (double) bits_version2 * lambda_picture + snrY_version2;
00031
00032 if (cost_version2 > cost_version1 || (cost_version2 == cost_version1 && snrY_version2 >= snrY_version1) )
00033 return (0);
00034 else
00035 return (1);
00036 }
00037
00038
00039
00040
00041
00042
00043
00044 int picture_coding_decision (ImageParameters *p_Img, InputParameters *p_Inp, Picture *picture1, Picture *picture2, int qp)
00045 {
00046 double lambda_picture;
00047 double sse_picture1, sse_picture2;
00048
00049 if (p_Inp->NumberBFrames)
00050 lambda_picture = (qp < 20 ? 0.55 : 0.68) * pow (2, (qp - SHIFT_QP) / 3.0) * ((p_Img->type == B_SLICE) || (p_Img->type == SP_SLICE) ? 2 : 1);
00051 else
00052 lambda_picture = (qp < 20 ? 0.55 : 0.68) * pow (2, (qp - SHIFT_QP) / 3.0);
00053
00054 sse_picture1 = picture1->distortion.value[0] + picture1->distortion.value[1] + picture1->distortion.value[2];
00055 sse_picture2 = picture2->distortion.value[0] + picture2->distortion.value[1] + picture2->distortion.value[2];
00056
00057 return rd_pic_decision(sse_picture1, sse_picture2, picture1->bits_per_picture, picture2->bits_per_picture, lambda_picture);
00058 }
00059