#include "simple_video_processor.h"
#include <iostream>
#include <cassert>
#include <algorithm>

bytertc::IVideoFrame* SimpleVideoProcessor::processVideoFrame(bytertc::IVideoFrame* src_frame) {
    int width = src_frame->width();
    int height = src_frame->height();
    int chrama_width = (width + 1) / 2;
    int chrama_height = (height + 1) / 2;

    // add color effect.
    for(int i(0); i < 3; i++) {
        uint8_t* src_plane_data = src_frame->getPlaneData(i);
        int stride = src_frame->getPlaneStride(i);
        uint8_t* src_addr = (uint8_t*)(src_plane_data);
        int region_h = i == 0? (height + 1) / 2 : (chrama_height + 1) / 2;
        int region_w = i == 0? (width + 7) / 8 : (chrama_width + 7) / 8;
        for(int h(0); h < region_h; h++) {
            for (int w(0); w < region_w; w++) {
                src_addr[w] = 0;
            }
            src_addr += stride;
        }
    }
    return src_frame;
}
