Skip to content

Commit

Permalink
Add RAW only save, fix 16:9 save
Browse files Browse the repository at this point in the history
  • Loading branch information
eszdman committed Jul 11, 2024
1 parent 0d3f970 commit a108ede
Show file tree
Hide file tree
Showing 30 changed files with 92 additions and 74 deletions.
12 changes: 9 additions & 3 deletions app/src/main/assets/shaders/addwatermark_rotate.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ uniform sampler2D InputBuffer;
uniform sampler2D Watermark;
uniform int yOffset;
uniform int rotate;
uniform ivec2 cropSize;
uniform ivec2 rawSize;
out vec4 Output;
#define WATERMARK 1
#define watersizek (15.0)
Expand All @@ -19,18 +21,22 @@ void main() {
xy+=ivec2(0,yOffset)+ivec2(OFFSET);
switch(rotate){
case 0:
xy += ivec2(0,(rawSize.y-cropSize.y));
cr = (vec2(xy+ivec2(0,-texSize.y))/(texS));
Output = texelFetch(InputBuffer, (xy), 0);
Output = texelFetch(InputBuffer, xy, 0);
break;
case 1:
cr = (vec2(xy+ivec2(0,-texSize.x))/(texS));
xy += ivec2((rawSize.y-cropSize.y),0);
cr = (vec2(xy+ivec2(-(rawSize.y-cropSize.y),-cropSize.x))/(texS));
Output = texelFetch(InputBuffer, ivec2(texSize.x-xy.y,xy.x), 0);
break;
case 2:
cr = (vec2(xy+ivec2(0,-texSize.y))/(texS));
//xy += ivec2(0,-(texSize.y-rotatedSize.y)/4);
cr = (vec2(xy+ivec2(0,-cropSize.y))/(texS));
Output = texelFetch(InputBuffer, ivec2(texSize.x-xy.x,texSize.y-xy.y), 0);
break;
case 3:
//xy += ivec2(-(texSize.x-rotatedSize.x)/4,0);
cr = (vec2(xy+ivec2(0,-texSize.x))/(texS));
Output = texelFetch(InputBuffer, ivec2(xy.y,texSize.y-xy.x),0);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Settings {
public double compressor;
public double gain;
public double shadows;
public boolean rawSaver;
public int rawSaver;
public boolean QuadBayer;
public int cfaPattern;
public int theme;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void loadCache() {
shadows = PreferenceKeys.getFloat(PreferenceKeys.Key.KEY_SHADOWS_SEEKBAR);
hdrx = PreferenceKeys.isHdrxNrOn();
cfaPattern = PreferenceKeys.getCFAValue();
rawSaver = PreferenceKeys.isSaveRawOn();
rawSaver = PreferenceKeys.isSaveRaw();
remosaic = PreferenceKeys.isRemosaicOn();
eisPhoto = PreferenceKeys.isEisPhotoOn();
QuadBayer = PreferenceKeys.isQuadBayerOn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class PostPipeline extends GLBasePipeline {
public GLTexture GainMap;
public ArrayList<Bitmap> debugData = new ArrayList<>();
public ArrayList<ImageFrame> SAGAIN;
public Point cropSize;
public float[] analyzedBL = new float[]{0.f, 0.f, 0.f};
;
float regenerationSense = 1.f;
Expand Down Expand Up @@ -85,23 +86,25 @@ public Bitmap Run(ByteBuffer inBuffer, Parameters parameters) {
noiseO = Math.max(noiseO, Float.MIN_NORMAL);
noiseS = Math.max(noiseS, Float.MIN_NORMAL);
Point rawSliced = parameters.rawSize;
cropSize = new Point(parameters.rawSize);
if (PhotonCamera.getSettings().aspect169) {
if (rawSliced.x > rawSliced.y) {
rawSliced = new Point(rawSliced.x, rawSliced.x * 9 / 16);
} else {
rawSliced = new Point(rawSliced.y * 9 / 16, rawSliced.y);
}
cropSize = new Point(rawSliced);
}
Point rotated = getRotatedCoords(rawSliced);
Point rotatedSize = getRotatedCoords(rawSliced);
if (PhotonCamera.getSettings().energySaving || mParameters.rawSize.x * mParameters.rawSize.y < ResolutionSolution.smallRes) {
GLDrawParams.TileSize = 8;
} else {
GLDrawParams.TileSize = 256;
}
GLFormat format = new GLFormat(GLFormat.DataType.SIMPLE_8, 4);
GLImage output = new GLImage(rotated, format);
GLImage output = new GLImage(rotatedSize, format);

GLCoreBlockProcessing glproc = new GLCoreBlockProcessing(rotated, output, format);
GLCoreBlockProcessing glproc = new GLCoreBlockProcessing(rotatedSize, output, format);
glint = new GLInterface(glproc);
stackFrame = inBuffer;
glint.parameters = parameters;
Expand Down Expand Up @@ -132,7 +135,7 @@ private void BuildDefaultPipeline() {
//add(new ESD3DBayerCS());
//}
if(mSettings.alignAlgorithm != 2) {
add(new Demosaic2());
add(new Demosaic3());
}

//add(new ImpulsePixelFilter());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package com.particlesdevs.photoncamera.processing.opengl.postpipeline;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.opengl.GLUtils;
import android.util.Log;

import com.particlesdevs.photoncamera.R;
import com.particlesdevs.photoncamera.app.PhotonCamera;
import com.particlesdevs.photoncamera.processing.opengl.GLImage;
import com.particlesdevs.photoncamera.processing.opengl.GLTexture;
import com.particlesdevs.photoncamera.processing.opengl.nodes.Node;
import com.particlesdevs.photoncamera.settings.PreferenceKeys;
import com.particlesdevs.photoncamera.util.FileManager;

import java.io.File;
import java.io.IOException;

import static android.opengl.GLES20.GL_CLAMP_TO_EDGE;
Expand Down Expand Up @@ -42,6 +35,7 @@ public void Run() {

//else lutbm = BitmapFactory.decodeResource(PhotonCamera.getResourcesStatic(), R.drawable.neutral_lut);
glProg.setDefine("WATERMARK",watermarkNeeded);

glProg.useAssetProgram("addwatermark_rotate");
try {
watermark = new GLImage(PhotonCamera.getAssetLoader().getInputStream("watermark/photoncamera_watermark.png"));
Expand Down Expand Up @@ -73,5 +67,10 @@ public void Run() {
}
Log.d(Name,"selected rotation:"+rot);
glProg.setVar("rotate",rot);
glProg.setVar("cropSize",((PostPipeline)basePipeline).cropSize);
glProg.setVar("rawSize",basePipeline.mParameters.rawSize);
Log.d(Name,"Crop size:"+((PostPipeline)basePipeline).cropSize);
Log.d(Name,"Raw size:"+basePipeline.mParameters.rawSize);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class HdrxProcessor extends ProcessorBase {
private int imageFormat;
/* config */
private int alignAlgorithm;
private boolean saveRAW;
private int saveRAW;
private CameraMode cameraMode;
private ArrayList<GyroBurst> BurstShakiness;

Expand All @@ -45,7 +45,7 @@ public HdrxProcessor(ProcessingEventsListener processingEventsListener) {
super(processingEventsListener);
}

public void configure(int alignAlgorithm, boolean saveRAW, CameraMode cameraMode) {
public void configure(int alignAlgorithm, int saveRAW, CameraMode cameraMode) {
this.alignAlgorithm = alignAlgorithm;
this.saveRAW = saveRAW;
this.cameraMode = cameraMode;
Expand Down Expand Up @@ -255,14 +255,8 @@ private void ApplyHdrX() {
Wrapper.outputBuffer(output);
Wrapper.processFrame(NoiseS, NoiseO, 1.5f, 1, 0.f, 0.f, 0.f, processingParameters.whiteLevel
, processingParameters.whitePoint[0], processingParameters.whitePoint[1], processingParameters.whitePoint[2], processingParameters.cfaPattern);
if (saveRAW){
for (int i = 1; i < images.size(); i++) {
images.get(i).image.close();
}
} else {
for (int i = 1; i < images.size(); i++) {
images.get(i).image.close();
}
for (int i = 1; i < images.size(); i++) {
images.get(i).image.close();
}
} else {
WrapperGPU.loadInterpolatedGainMap(interpolateGainMap.Output);
Expand All @@ -272,14 +266,8 @@ private void ApplyHdrX() {
Log.d(TAG, "Packing");
WrapperGPU.packImages();
Log.d(TAG, "Packed");
if (saveRAW){
for (int i = 1; i < images.size(); i++) {
images.get(i).image.close();
}
} else {
for (int i = 1; i < images.size(); i++) {
images.get(i).image.close();
}
for (int i = 1; i < images.size(); i++) {
images.get(i).image.close();
}
if(alignAlgorithm == 1) {
float bl = processingParameters.blackLevel[0]+processingParameters.blackLevel[1]+processingParameters.blackLevel[2]+processingParameters.blackLevel[3];
Expand All @@ -305,7 +293,7 @@ private void ApplyHdrX() {
} else {
result = output;
}
if (saveRAW && alignAlgorithm != 2) {
if ((saveRAW >= 1) && alignAlgorithm != 2) {
int patchWL = (int) FAKE_WL;

Camera2ApiAutoFix.patchWL(characteristics, captureResult, patchWL);
Expand All @@ -326,6 +314,12 @@ private void ApplyHdrX() {
parameters.blackLevel[1] -= bl;
parameters.blackLevel[2] -= bl;
parameters.blackLevel[3] = 0.f;*/
if (saveRAW == 2) {
processingEventsListener.onProcessingFinished("HdrX RAW Processing Finished");
callback.onFinished();
images.get(0).image.close();
return;
}
}
/*else {
if(alignAlgorithm == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public class UnlimitedProcessor extends ProcessorBase {
private boolean fillParams = false;

/* config */
private boolean saveRAW;
private int saveRAW;

public UnlimitedProcessor(ProcessingEventsListener processingEventsListener) {
super(processingEventsListener);
}

public void configure(boolean saveRAW) {
public void configure(int saveRAW) {
this.saveRAW = saveRAW;
}

Expand Down Expand Up @@ -111,7 +111,7 @@ private void processUnlimited(Image image) {
image.getPlanes()[0].getBuffer().position(0);
averageRaw.close();
averageRaw = null;
if (saveRAW) {
if (saveRAW >= 1) {

processingEventsListener.onProcessingFinished("Unlimited rawSaver Processing Finished");

Expand All @@ -123,8 +123,11 @@ private void processUnlimited(Image image) {
Camera2ApiAutoFix.resetWL(characteristics, captureResult, (int) FAKE_WL);

processingEventsListener.notifyImageSavedStatus(imageSaved, dngFile);

return;
if (saveRAW == 2) {
processingEventsListener.onProcessingFinished("Unlimited RAW Processing Finished");
callback.onFinished();
return;
}
}

IncreaseWLBL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.hardware.camera2.CameraManager;
import android.util.Log;

import androidx.annotation.StringRes;
Expand All @@ -12,7 +11,6 @@
import com.google.gson.GsonBuilder;
import com.hunter.library.debug.HunterDebug;
import com.particlesdevs.photoncamera.R;
import com.particlesdevs.photoncamera.api.CameraManager2;
import com.particlesdevs.photoncamera.app.PhotonCamera;

import java.util.Arrays;
Expand All @@ -21,8 +19,6 @@
import java.util.Map;
import java.util.Set;

import static android.content.Context.CAMERA_SERVICE;

/**
* Created by Vibhor 06/09/2020
*/
Expand Down Expand Up @@ -190,8 +186,8 @@ public static boolean isHdrxNrOn() {
return preferenceKeys.settingsManager.getBoolean(SCOPE_GLOBAL, Key.KEY_HDRX_NR);
}

public static boolean isSaveRawOn() {
return preferenceKeys.settingsManager.getBoolean(SCOPE_GLOBAL, Key.KEY_SAVE_RAW);
public static int isSaveRaw() {
return preferenceKeys.settingsManager.getInteger(SCOPE_GLOBAL, Key.KEY_SAVE_RAW);
}

public static boolean isBatterySaverOn(){
Expand All @@ -204,7 +200,7 @@ public static boolean isAspect169On(){
public static void setBatterySaver(boolean value) {
preferenceKeys.settingsManager.set(SCOPE_GLOBAL, Key.KEY_ENERGY_SAVING,value);
}
public static void setSaveRaw(boolean value) {
public static void setSaveRaw(int value) {
preferenceKeys.settingsManager.set(SCOPE_GLOBAL, Key.KEY_SAVE_RAW,value);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.particlesdevs.photoncamera.ui;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.particlesdevs.photoncamera.AiPhoto;
import com.particlesdevs.photoncamera.ui.camera.CameraActivity;
import com.particlesdevs.photoncamera.util.FileManager;

import java.io.File;
Expand All @@ -30,7 +32,7 @@ protected void onCreate(Bundle savedInstanceState) {
} catch (IOException e) {
e.printStackTrace();
}
AiPhoto.initAi(this);
startActivity(new Intent(SplashActivity.this, CameraActivity.class));
finish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public void onChanged(TopBarSettingsData<?, ?> topBarSettingsData) {
PreferenceKeys.setEisPhoto(value.equals(1));
break;
case RAW:
PreferenceKeys.setSaveRaw(value.equals(1));
PreferenceKeys.setSaveRaw((Integer) value);
break;
case BATTERY_SAVER:
PreferenceKeys.setBatterySaver(value.equals(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void updateAllEntries() {
updateEntry(eisEntry, PreferenceKeys.isEisPhotoOn());
updateEntry(fpsEntry, PreferenceKeys.isFpsPreviewOn());
updateEntry(quadEntry, PreferenceKeys.isQuadBayerOn());
updateEntry(saveRawEntry, PreferenceKeys.isSaveRawOn());
updateEntry(saveRawEntry, PreferenceKeys.isSaveRaw());
updateEntry(batterySaverEntry, PreferenceKeys.isBatterySaverOn());
}

Expand Down Expand Up @@ -120,7 +120,8 @@ private void createEisEntry() {
private void createSaveRawEntry() {
saveRawEntry.addSettingsBarButtonModels(
SettingsBarButtonModel.newButtonModel(R.id.raw_off_button, R.drawable.ic_raw_off, R.string.jpg_only, 0, saveRawEntry),
SettingsBarButtonModel.newButtonModel(R.id.raw_on_button, R.drawable.ic_raw, R.string.raw_plus_jpg, 1, saveRawEntry)
SettingsBarButtonModel.newButtonModel(R.id.raw_on_button, R.drawable.ic_raw, R.string.raw_plus_jpg, 1, saveRawEntry),
SettingsBarButtonModel.newButtonModel(R.id.raw_only_button, R.drawable.ic_raw, R.string.raw_string, 2, saveRawEntry)
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<string name="saturation">Sytost barev</string>
<string name="sharpness">Ostrost</string>
<string name="turn_on_grid">Zobrazit mřížku</string>
<string name="raw">Uložit RAW + JPEG</string>
<string name="raw">Uložit</string>
<string name="turn_on_round_edges">Zaoblené rohy</string>
<string name="enable_remosaic">Povolit Re-Mosaikování</string>
<string name="general">Obecné</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<string name="saturation">Saturacion</string>
<string name="sharpness">Nitidez</string>
<string name="turn_on_grid">Mostrar cuadricula</string>
<string name="raw">Guardar RAW + JPEG</string>
<string name="raw">Guardar</string>
<string name="turn_on_round_edges">Activar bordes redondos</string>
<string name="enable_remosaic">Activar remosaico</string>
<string name="general">General</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<string name="saturation">Zasićenje bojom</string>
<string name="sharpness">Oštrina</string>
<string name="turn_on_grid">Pokaži rešetku</string>
<string name="raw">Spremi RAW + JPEG</string>
<string name="raw">Spremi</string>
<string name="turn_on_round_edges">Omogući zakrivljene rubove:</string>
<string name="enable_remosaic">Omogući Remosaic</string>
<string name="general">Općenito</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<string name="saturation">Saturasi</string>
<string name="sharpness">Ketajaman Gambar</string>
<string name="turn_on_grid">Perlihatkan Garis Penanda</string>
<string name="raw">Simpan dokumen RAW + JPEG</string>
<string name="raw">Simpan dokumen</string>
<string name="turn_on_round_edges">Aktifkan garis tepi membulat</string>
<string name="enable_remosaic">Aktifkan Remosaic</string>
<string name="general">Umum</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<string name="saturation">Saturazione</string>
<string name="sharpness">Nitidezza</string>
<string name="turn_on_round_edges">Mostra angoli curvi</string>
<string name="raw">Salva RAW + JPEG</string>
<string name="raw">Salva</string>
<string name="general">Generali</string>
<string name="hdrxNR">Riduzione del rumore</string>
<string name="turn_on_watermark">Abilita filigrana</string>
Expand Down
Loading

0 comments on commit a108ede

Please sign in to comment.