⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recon.c

📁 DirectFB-1.0.1可用于linux的嵌入式GUI
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Predict.c, motion compensation routines                                    *//* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. *//* * Disclaimer of Warranty * * These software programs are available to the user without any license fee or * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims * any and all warranties, whether express, implied, or statuary, including any * implied warranties or merchantability or of fitness for a particular * purpose.  In no event shall the copyright-holder be liable for any * incidental, punitive, or consequential damages of any kind whatsoever * arising from the use of these programs. * * This disclaimer of warranty extends to the user of these programs and user's * customers, employees, agents, transferees, successors, and assigns. * * The MPEG Software Simulation Group does not represent or warrant that the * programs furnished hereunder are free of infringement of any third-party * patents. * * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, * are subject to royalty fees to patent holders.  Many of these patents are * general enough such that they are unavoidable regardless of implementation * design. * */#include <stdio.h>#include "global.h"/* private prototypes */static void form_prediction (MPEG2_Decoder *dec, unsigned char *src[], int sfield,                             unsigned char *dst[], int dfield,                             int lx, int lx2, int w, int h, int x, int y, int dx, int dy,                             int average_flag);static void form_component_prediction (MPEG2_Decoder *dec, unsigned char *src, unsigned char *dst,                                       int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag);voidMPEG2_form_predictions(MPEG2_Decoder *dec,                       int bx, int by,                       int macroblock_type,                       int motion_type,                       int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2],                       int stwtype){     int currentfield;     unsigned char **predframe;     int DMV[2][2];     int stwtop, stwbot;     stwtop = stwtype%3; /* 0:temporal, 1:(spat+temp)/2, 2:spatial */     stwbot = stwtype/3;     if ((macroblock_type & MACROBLOCK_MOTION_FORWARD)          || (dec->picture_coding_type==P_TYPE)) {          if (dec->picture_structure==FRAME_PICTURE) {               if ((motion_type==MC_FRAME)                    || !(macroblock_type & MACROBLOCK_MOTION_FORWARD)) {                    /* frame-based prediction (broken into top and bottom halves                         for spatial scalability prediction purposes) */                    if (stwtop<2)                         form_prediction(dec, dec->forward_reference_frame,0,dec->current_frame,0,                                         dec->Coded_Picture_Width,dec->Coded_Picture_Width<<1,16,8,bx,by,                                         PMV[0][0][0],PMV[0][0][1],stwtop);                    if (stwbot<2)                         form_prediction(dec, dec->forward_reference_frame,1,dec->current_frame,1,                                         dec->Coded_Picture_Width,dec->Coded_Picture_Width<<1,16,8,bx,by,                                         PMV[0][0][0],PMV[0][0][1],stwbot);               }               else if (motion_type==MC_FIELD) { /* field-based prediction */                    /* top field prediction */                    if (stwtop<2)                         form_prediction(dec, dec->forward_reference_frame,motion_vertical_field_select[0][0],                                         dec->current_frame,0,dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,                                         bx,by>>1,PMV[0][0][0],PMV[0][0][1]>>1,stwtop);                    /* bottom field prediction */                    if (stwbot<2)                         form_prediction(dec, dec->forward_reference_frame,motion_vertical_field_select[1][0],                                         dec->current_frame,1,dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,                                         bx,by>>1,PMV[1][0][0],PMV[1][0][1]>>1,stwbot);               }               else if (motion_type==MC_DMV) { /* dual prime prediction */                    /* calculate derived motion vectors */                    MPEG2_Dual_Prime_Arithmetic(dec, DMV,dmvector,PMV[0][0][0],PMV[0][0][1]>>1);                    if (stwtop<2) {                         /* predict top field from top field */                         form_prediction(dec, dec->forward_reference_frame,0,dec->current_frame,0,                                         dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,bx,by>>1,                                         PMV[0][0][0],PMV[0][0][1]>>1,0);                         /* predict and add to top field from bottom field */                         form_prediction(dec, dec->forward_reference_frame,1,dec->current_frame,0,                                         dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,bx,by>>1,                                         DMV[0][0],DMV[0][1],1);                    }                    if (stwbot<2) {                         /* predict bottom field from bottom field */                         form_prediction(dec, dec->forward_reference_frame,1,dec->current_frame,1,                                         dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,bx,by>>1,                                         PMV[0][0][0],PMV[0][0][1]>>1,0);                         /* predict and add to bottom field from top field */                         form_prediction(dec, dec->forward_reference_frame,0,dec->current_frame,1,                                         dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,bx,by>>1,                                         DMV[1][0],DMV[1][1],1);                    }               }               else                    /* invalid motion_type */                    printf("invalid motion_type\n");          }          else { /* TOP_FIELD or BOTTOM_FIELD */               /* field picture */               currentfield = (dec->picture_structure==BOTTOM_FIELD);               /* determine which frame to use for prediction */               if ((dec->picture_coding_type==P_TYPE) && dec->Second_Field                   && (currentfield!=motion_vertical_field_select[0][0]))                    predframe = dec->backward_reference_frame; /* same frame */               else                    predframe = dec->forward_reference_frame; /* previous frame */               if ((motion_type==MC_FIELD)                   || !(macroblock_type & MACROBLOCK_MOTION_FORWARD)) {                    /* field-based prediction */                    if (stwtop<2)                         form_prediction(dec, predframe,motion_vertical_field_select[0][0],dec->current_frame,0,                                         dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,16,bx,by,                                         PMV[0][0][0],PMV[0][0][1],stwtop);               }               else if (motion_type==MC_16X8) {                    if (stwtop<2) {                         form_prediction(dec, predframe,motion_vertical_field_select[0][0],dec->current_frame,0,                                         dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,bx,by,                                         PMV[0][0][0],PMV[0][0][1],stwtop);                         /* determine which frame to use for lower half prediction */                         if ((dec->picture_coding_type==P_TYPE) && dec->Second_Field                             && (currentfield!=motion_vertical_field_select[1][0]))                              predframe = dec->backward_reference_frame; /* same frame */                         else                              predframe = dec->forward_reference_frame; /* previous frame */                         form_prediction(dec, predframe,motion_vertical_field_select[1][0],dec->current_frame,0,                                         dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,bx,by+8,                                         PMV[1][0][0],PMV[1][0][1],stwtop);                    }               }               else if (motion_type==MC_DMV) { /* dual prime prediction */                    if (dec->Second_Field)                         predframe = dec->backward_reference_frame; /* same frame */                    else                         predframe = dec->forward_reference_frame; /* previous frame */                    /* calculate derived motion vectors */                    MPEG2_Dual_Prime_Arithmetic(dec, DMV,dmvector,PMV[0][0][0],PMV[0][0][1]);                    /* predict from field of same parity */                    form_prediction(dec, dec->forward_reference_frame,currentfield,dec->current_frame,0,                                    dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,16,bx,by,                                    PMV[0][0][0],PMV[0][0][1],0);                    /* predict from field of opposite parity */                    form_prediction(dec, predframe,!currentfield,dec->current_frame,0,                                    dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,16,bx,by,                                    DMV[0][0],DMV[0][1],1);               }               else                    /* invalid motion_type */                    printf("invalid motion_type\n");          }          stwtop = stwbot = 1;     }     if (macroblock_type & MACROBLOCK_MOTION_BACKWARD) {          if (dec->picture_structure==FRAME_PICTURE) {               if (motion_type==MC_FRAME) {                    /* frame-based prediction */                    if (stwtop<2)                         form_prediction(dec, dec->backward_reference_frame,0,dec->current_frame,0,                                         dec->Coded_Picture_Width,dec->Coded_Picture_Width<<1,16,8,bx,by,                                         PMV[0][1][0],PMV[0][1][1],stwtop);                    if (stwbot<2)                         form_prediction(dec, dec->backward_reference_frame,1,dec->current_frame,1,                                         dec->Coded_Picture_Width,dec->Coded_Picture_Width<<1,16,8,bx,by,                                         PMV[0][1][0],PMV[0][1][1],stwbot);               }               else { /* field-based prediction */                    /* top field prediction */                    if (stwtop<2)                         form_prediction(dec, dec->backward_reference_frame,motion_vertical_field_select[0][1],                                         dec->current_frame,0,dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,                                         bx,by>>1,PMV[0][1][0],PMV[0][1][1]>>1,stwtop);                    /* bottom field prediction */                    if (stwbot<2)                         form_prediction(dec, dec->backward_reference_frame,motion_vertical_field_select[1][1],                                         dec->current_frame,1,dec->Coded_Picture_Width<<1,dec->Coded_Picture_Width<<1,16,8,                                         bx,by>>1,PMV[1][1][0],PMV[1][1][1]>>1,stwbot);               }          }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -