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 (Picture *picture1, Picture *picture2, int qp)
00045 {
00046 double lambda_picture;
00047 int spframe = (img->type == SP_SLICE);
00048 int bframe = (img->type == B_SLICE);
00049 double sse_picture1, sse_picture2;
00050
00051 if (params->NumberBFrames)
00052 lambda_picture = (qp < 20 ? 0.55 : 0.68) * pow (2, (qp - SHIFT_QP) / 3.0) * (bframe || spframe ? 2 : 1);
00053 else
00054 lambda_picture = (qp < 20 ? 0.55 : 0.68) * pow (2, (qp - SHIFT_QP) / 3.0);
00055
00056 sse_picture1 = picture1->distortion.value[0] + picture1->distortion.value[1] + picture1->distortion.value[2];
00057 sse_picture2 = picture2->distortion.value[0] + picture2->distortion.value[1] + picture2->distortion.value[2];
00058
00059 return rd_pic_decision(sse_picture1, sse_picture2, picture1->bits_per_picture, picture2->bits_per_picture, lambda_picture);
00060 }
00061