Skip to content

Commit

Permalink
Easy editing support
Browse files Browse the repository at this point in the history
crop, resize, mirror, rotate
  • Loading branch information
DichenZhang1 committed Feb 1, 2024
1 parent 2b03191 commit a5476d4
Show file tree
Hide file tree
Showing 6 changed files with 904 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
# File Lists
###########################################################
file(GLOB UHDR_LIB_LIST "${SOURCE_DIR}/src/*.cpp")
file(GLOB UHDR_TEST_LIST "${TESTS_DIR}/*.cpp")
file(GLOB UHDR_TEST_LIST "${TESTS_DIR}/editorhelper_test.cpp")
file(GLOB UHDR_BM_LIST "${BENCHMARK_DIR}/*.cpp")
file(GLOB IMAGE_IO_LIST "${THIRD_PARTY_DIR}/image_io/src/**/*.cc")

Expand Down
48 changes: 48 additions & 0 deletions lib/include/ultrahdr/editorhelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef ULTRAHDR_EDITORHELPER_H
#define ULTRAHDR_EDITORHELPER_H

#include "ultrahdr/ultrahdr.h"
#include "ultrahdr/jpegr.h"

namespace ultrahdr {
typedef enum {
ULTRAHDR_MIRROR_VERTICAL,
ULTRAHDR_MIRROR_HORIZONTAL,
} ultrahdr_mirroring_direction;

status_t crop(jr_uncompressed_ptr const in_img,
int left, int right, int top, int bottom, jr_uncompressed_ptr out_img,
ultrahdr_pixel_format pix_fmt = ultrahdr_pixel_format::ULTRAHDR_PIX_FMT_YUV420);

status_t mirror(jr_uncompressed_ptr const in_img,
ultrahdr_mirroring_direction mirror_dir,
jr_uncompressed_ptr out_img,
ultrahdr_pixel_format pix_fmt = ultrahdr_pixel_format::ULTRAHDR_PIX_FMT_YUV420);

status_t rotate(jr_uncompressed_ptr const in_img, int clockwise_degree,
jr_uncompressed_ptr out_img,
ultrahdr_pixel_format pix_fmt = ultrahdr_pixel_format::ULTRAHDR_PIX_FMT_YUV420);

status_t resize(jr_uncompressed_ptr const in_img, int out_width, int out_height,
jr_uncompressed_ptr out_img,
ultrahdr_pixel_format pix_fmt = ultrahdr_pixel_format::ULTRAHDR_PIX_FMT_YUV420);

} // namespace ultrahdr

#endif // ULTRAHDR_EDITORHELPER_H
1 change: 1 addition & 0 deletions lib/include/ultrahdr/jpegr.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef enum {
ERROR_JPEGR_INVALID_DISPLAY_BOOST = JPEGR_IO_ERROR_BASE - 8,
ERROR_JPEGR_INVALID_OUTPUT_FORMAT = JPEGR_IO_ERROR_BASE - 9,
ERROR_JPEGR_BAD_METADATA = JPEGR_IO_ERROR_BASE - 10,
ERROR_JPEGR_INVALID_CROPPING_PARAMETERS = JPEGR_IO_ERROR_BASE - 11,

JPEGR_RUNTIME_ERROR_BASE = -20000,
ERROR_JPEGR_ENCODE_ERROR = JPEGR_RUNTIME_ERROR_BASE - 1,
Expand Down
11 changes: 11 additions & 0 deletions lib/include/ultrahdr/ultrahdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ typedef enum {
ULTRAHDR_OUTPUT_MAX = ULTRAHDR_OUTPUT_HDR_HLG,
} ultrahdr_output_format;

// Supported pixel format
typedef enum {
ULTRAHDR_PIX_FMT_UNSPECIFIED = -1,
ULTRAHDR_PIX_FMT_P010,
ULTRAHDR_PIX_FMT_YUV420,
ULTRAHDR_PIX_FMT_MONOCHROME,
ULTRAHDR_PIX_FMT_RGBA8888,
ULTRAHDR_PIX_FMT_RGBAF16,
ULTRAHDR_PIX_FMT_RGBA1010102,
} ultrahdr_pixel_format;

/*
* Holds information for gain map related metadata.
*
Expand Down
Loading

0 comments on commit a5476d4

Please sign in to comment.