Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 5 additions & 112 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,118 +40,11 @@ jobs:
cancel-in-progress: true

steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.3

- uses: actions/setup-node@v3
with:
node-version: "18"

- name: Install Yarn
run: npm install -g yarn

- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive

- id: cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
echo "::set-output name=pwd::$(pwd)"

- name: Results Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-paths.outputs.pwd }}/cpp/out
key: ${{ runner.os }}-results-${{ hashFiles('cpp/third-party/Makefile') }}

- name: External Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-paths.outputs.pwd }}/cpp/third-party/build
key: ${{ runner.os }}-external-build-${{ hashFiles('cpp/third-party/Makefile') }}

- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('go.sum') }}

- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('go.sum') }}

- name: GoLint Cache
uses: actions/cache@v3
with:
path: ${{ env.GOLANGCI_LINT_CACHE }}
key: ${{ runner.os }}-go-lint-ci

- name: Node Modules Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}

- name: Setup | Rust
uses: ATiltedTree/setup-rust@v1
with:
rust-version: stable

- name: Install Development Dependencies
run: make dev_deps

- name: Run Linter
run: make lint

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
ca-certificates \
build-essential \
curl \
ninja-build \
meson \
git \
nasm \
openssl \
pkg-config \
cmake \
libssl-dev \
libpng-dev \
zlib1g-dev \
libx264-dev \
libx265-dev \
libvpx-dev \
libopenjp2-7-dev \
libssl-dev \
gifsicle \
optipng

- name: Compile External Dependencies
run: make -C cpp external

- name: Build CPP Applications
run: make -C cpp build

- name: Move built files to /usr/local
run: |
sudo cp -r cpp/out/* /usr/local
sudo ldconfig

- name: Run Tests
run: make test

- name: Build App
run: make build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
if: ${{ env.DEPLOY_PROD == 'true' || env.DEPLOY_STAGE == 'true' }}
Expand Down Expand Up @@ -182,11 +75,11 @@ jobs:
if: ${{ env.DEPLOY_PROD == 'true' || env.DEPLOY_STAGE == 'true' }}
with:
context: .
file: docker/partial.Dockerfile
# cache-from: |
# type=registry,ref=gha
# cache-to: |
# type=registry,ref=gha,mode=max
file: docker/full.Dockerfile
cache-from: |
type=gha
cache-to: |
type=gha,mode=max
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ (env.DEPLOY_PROD == 'true' && '7tv') || '7tv-stage' }}/image-processor:latest
${{ steps.login-ecr.outputs.registry }}/${{ (env.DEPLOY_PROD == 'true' && '7tv') || '7tv-stage' }}/image-processor:${{ github.sha }}
Expand Down
41 changes: 29 additions & 12 deletions go/internal/image_processor/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,23 +730,40 @@ func (Worker) resizeFrames(ctx global.Context, inputDir string, tmpDir string, t
}

if tsk.ResizeRatio == task.ResizeRatioNothing {
smwf := float64(tsk.SmallestMaxWidth)
wf := float64(width)
smhf := float64(tsk.SmallestMaxHeight)
hf := float64(height)
// Get the largest scale factor
scale := 1
for _, s := range tsk.Scales {
if s > scale {
scale = s
}
}

// Divide the width and height by the scale factor
// This is integer division, so it will round down
width /= scale
height /= scale

if smwf < wf {
hf *= smwf / wf
wf = smwf
// If the height is bigger than the max height, then scale it down
if height > tsk.SmallestMaxHeight {
width = int(float64(width) * (float64(tsk.SmallestMaxHeight) / float64(height)))
height = tsk.SmallestMaxHeight
}

if smhf < hf {
wf *= smhf / hf
hf = smhf
// If the width is bigger than the max width, then scale it down
if width > tsk.SmallestMaxWidth {
height = int(float64(height) * (float64(tsk.SmallestMaxWidth) / float64(width)))
width = tsk.SmallestMaxWidth
}

width = int(math.Round(wf))
height = int(math.Round(hf))
// If the width is 0, then set it to 1
if width == 0 {
width = 1
}

// If the height is 0, then set it to 1
if height == 0 {
height = 1
}

tsk.ResizeRatio = task.ResizeRatioStretch
} else {
Expand Down