Code Monkey home page Code Monkey logo

th_encode_erase's Introduction

th_encode_erase

#import "1.1/th_dec_ctx.h"

#define CLIP(X) ((X)>0xFF?0xFF:(X)<0?0:X)

// RGB -> YUV
#define RGB2Y(R,G,B) CLIP((( 66*(R)+129*(G)+ 25*(B)+128)>>8)+ 16)
#define RGB2U(R,G,B) CLIP(((-38*(R)- 74*(G)+112*(B)+128)>>8)+128)
#define RGB2V(R,G,B) CLIP(((112*(R)- 94*(G)- 18*(B)+128)>>8)+128)

void th_encode_erase(th_dec_ctx *tcx) {
        
    int fw = tcx->state.info.frame_width;
    int fh = tcx->state.info.frame_height;

    /*
    OC_FRAME_GOLD (0)
    OC_FRAME_PREV (1)
    OC_FRAME_SELF (2)
    OC_FRAME_IO (3)
    */
        
    for(int k=0; k<2; k++) {
        
        int framei = tcx->state.ref_frame_idx[k];
        if(tcx->state.ref_frame_bufs[framei][0].width==fw&&tcx->state.ref_frame_bufs[framei][0].height==fh) {
            
            unsigned char *y_row= tcx->state.ref_frame_bufs[framei][0].data;
            unsigned char *u_row= tcx->state.ref_frame_bufs[framei][1].data;
            unsigned char *v_row= tcx->state.ref_frame_bufs[framei][2].data;
            int y_stride= tcx->state.ref_frame_bufs[framei][0].stride;
            int u_stride= tcx->state.ref_frame_bufs[framei][1].stride;
            int v_stride= tcx->state.ref_frame_bufs[framei][2].stride;
            
            for(int i=0; i<fh; i++) {
                
                int dc;
                
                unsigned char *y=y_row;
                unsigned char *u=u_row;
                unsigned char *v=v_row;
                
                for(int j=0; j<fw; j++) {
                    
                    *y=RGB2Y(0,0,0xFF);
                    *u=RGB2U(0,0,0xFF);
                    *v=RGB2V(0,0,0xFF);
                    
                    dc=(y-y_row&1)|(tcx->state.info.pixel_fmt&1);
                    
                    y++;
                    u+=dc;
                    v+=dc;
                }
                
                dc=-((i&1)|tcx->state.info.pixel_fmt>>1);
                y_row+=y_stride;
                u_row+=dc&u_stride;
                v_row+=dc&v_stride;
            }
        }
    }
}

th_encode_erase's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.