Home | History | Annotate | Download | only in source
      1 /*
      2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #include <stdlib.h>  // NULL
     12 
     13 #include "webrtc/modules/video_processing/main/source/color_enhancement.h"
     14 #include "webrtc/modules/video_processing/main/source/color_enhancement_private.h"
     15 
     16 namespace webrtc {
     17 namespace VideoProcessing {
     18 
     19 int32_t ColorEnhancement(I420VideoFrame* frame) {
     20   assert(frame);
     21   // Pointers to U and V color pixels.
     22   uint8_t* ptr_u;
     23   uint8_t* ptr_v;
     24   uint8_t temp_chroma;
     25   if (frame->IsZeroSize()) {
     26     return VPM_GENERAL_ERROR;
     27   }
     28   if (frame->width() == 0 || frame->height() == 0) {
     29     return VPM_GENERAL_ERROR;
     30   }
     31 
     32   // Set pointers to first U and V pixels (skip luminance).
     33   ptr_u = frame->buffer(kUPlane);
     34   ptr_v = frame->buffer(kVPlane);
     35   int size_uv = ((frame->width() + 1) / 2) * ((frame->height() + 1) / 2);
     36 
     37   // Loop through all chrominance pixels and modify color.
     38   for (int ix = 0; ix < size_uv; ix++) {
     39     temp_chroma = colorTable[*ptr_u][*ptr_v];
     40     *ptr_v = colorTable[*ptr_v][*ptr_u];
     41     *ptr_u = temp_chroma;
     42 
     43     ptr_u++;
     44     ptr_v++;
     45   }
     46   return VPM_OK;
     47 }
     48 
     49 }  // namespace VideoProcessing
     50 }  // namespace webrtc
     51