| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * FFV1 encoder template | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2003-2016 Michael Niedermayer <michaelni@gmx.at> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is part of FFmpeg. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * FFmpeg is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * FFmpeg is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License along with FFmpeg; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-16 22:24:24 +02:00
										 |  |  | #include "ffv1_template.c"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-07 19:46:20 +02:00
										 |  |  | static av_always_inline int | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  | RENAME(encode_line)(FFV1Context *f, FFV1SliceContext *sc, | 
					
						
							|  |  |  |                     void *logctx, | 
					
						
							| 
									
										
										
											
												avcodec/ffv1enc: Use dummies to avoid UB pointer arithmetic
Fixes the following FATE-tests when run under Clang-UBSan:
ffmpeg-loopback-decoding, lavf-mxf_ffv1,
vsynth{1,2,3,_lena}-ffv1-v{0,2}, vsynth1-ffv{1,2,3,_lena},
vsynth{1,2,3,_lena}-ffv1-v3-yuv{420p,422p10,444p16}
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
											
										 
											2025-06-22 23:25:34 +02:00
										 |  |  |                     int w, TYPE *const sample[3], int plane_index, int bits, | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  |                     int ac, int pass1) | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-07-08 18:01:13 +02:00
										 |  |  |     PlaneContext *const p = &sc->plane[plane_index]; | 
					
						
							| 
									
										
										
										
											2024-07-09 08:45:16 +02:00
										 |  |  |     RangeCoder *const c   = &sc->c; | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |     int x; | 
					
						
							| 
									
										
										
										
											2024-07-07 19:46:20 +02:00
										 |  |  |     int run_index = sc->run_index; | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |     int run_count = 0; | 
					
						
							|  |  |  |     int run_mode  = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-02 19:39:10 +02:00
										 |  |  |     if (bits == 0) | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-14 00:15:41 +02:00
										 |  |  |     if (sc->slice_coding_mode == 1) { | 
					
						
							|  |  |  |         av_assert0(ac != AC_GOLOMB_RICE); | 
					
						
							|  |  |  |         if (c->bytestream_end - c->bytestream < (w * bits + 7LL)>>3) { | 
					
						
							| 
									
										
										
										
											2025-03-09 23:38:29 +01:00
										 |  |  |             av_log(logctx, AV_LOG_ERROR, "encoded Range Coder frame too large\n"); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |             return AVERROR_INVALIDDATA; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (x = 0; x < w; x++) { | 
					
						
							|  |  |  |             int i; | 
					
						
							|  |  |  |             int v = sample[0][x]; | 
					
						
							|  |  |  |             for (i = bits-1; i>=0; i--) { | 
					
						
							|  |  |  |                 uint8_t state = 128; | 
					
						
							|  |  |  |                 put_rac(c, &state, (v>>i) & 1); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-14 00:15:41 +02:00
										 |  |  |     if (ac != AC_GOLOMB_RICE) { | 
					
						
							|  |  |  |         if (c->bytestream_end - c->bytestream < w * 35) { | 
					
						
							|  |  |  |             av_log(logctx, AV_LOG_ERROR, "encoded Range Coder frame too large\n"); | 
					
						
							|  |  |  |             return AVERROR_INVALIDDATA; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         if (put_bytes_left(&sc->pb, 0) < w * 4) { | 
					
						
							|  |  |  |             av_log(logctx, AV_LOG_ERROR, "encoded Golomb Rice frame too large\n"); | 
					
						
							|  |  |  |             return AVERROR_INVALIDDATA; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |     for (x = 0; x < w; x++) { | 
					
						
							|  |  |  |         int diff, context; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-08 12:22:57 +02:00
										 |  |  |         context = RENAME(get_context)(f->quant_tables[p->quant_table_index], | 
					
						
							|  |  |  |                                       sample[0] + x, sample[1] + x, sample[2] + x); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |         diff    = sample[0][x] - RENAME(predict)(sample[0] + x, sample[1] + x); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (context < 0) { | 
					
						
							|  |  |  |             context = -context; | 
					
						
							|  |  |  |             diff    = -diff; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         diff = fold(diff, bits); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-08 13:11:52 +02:00
										 |  |  |         if (ac != AC_GOLOMB_RICE) { | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  |             if (pass1) { | 
					
						
							| 
									
										
										
										
											2024-07-10 16:51:45 +02:00
										 |  |  |                 put_symbol_inline(c, p->state[context], diff, 1, sc->rc_stat, | 
					
						
							|  |  |  |                                   sc->rc_stat2[p->quant_table_index][context]); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 put_symbol_inline(c, p->state[context], diff, 1, NULL, NULL); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             if (context == 0) | 
					
						
							|  |  |  |                 run_mode = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (run_mode) { | 
					
						
							|  |  |  |                 if (diff) { | 
					
						
							|  |  |  |                     while (run_count >= 1 << ff_log2_run[run_index]) { | 
					
						
							|  |  |  |                         run_count -= 1 << ff_log2_run[run_index]; | 
					
						
							|  |  |  |                         run_index++; | 
					
						
							| 
									
										
										
										
											2024-07-08 10:14:55 +02:00
										 |  |  |                         put_bits(&sc->pb, 1, 1); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-08 10:14:55 +02:00
										 |  |  |                     put_bits(&sc->pb, 1 + ff_log2_run[run_index], run_count); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |                     if (run_index) | 
					
						
							|  |  |  |                         run_index--; | 
					
						
							|  |  |  |                     run_count = 0; | 
					
						
							|  |  |  |                     run_mode  = 0; | 
					
						
							|  |  |  |                     if (diff > 0) | 
					
						
							|  |  |  |                         diff--; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     run_count++; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  |             ff_dlog(logctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n", | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |                     run_count, run_index, run_mode, x, | 
					
						
							| 
									
										
										
										
											2024-07-08 10:14:55 +02:00
										 |  |  |                     (int)put_bits_count(&sc->pb)); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (run_mode == 0) | 
					
						
							| 
									
										
										
										
											2024-07-08 10:14:55 +02:00
										 |  |  |                 put_vlc_symbol(&sc->pb, &p->vlc_state[context], diff, bits); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (run_mode) { | 
					
						
							|  |  |  |         while (run_count >= 1 << ff_log2_run[run_index]) { | 
					
						
							|  |  |  |             run_count -= 1 << ff_log2_run[run_index]; | 
					
						
							|  |  |  |             run_index++; | 
					
						
							| 
									
										
										
										
											2024-07-08 10:14:55 +02:00
										 |  |  |             put_bits(&sc->pb, 1, 1); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (run_count) | 
					
						
							| 
									
										
										
										
											2024-07-08 10:14:55 +02:00
										 |  |  |             put_bits(&sc->pb, 1, 1); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-07 19:46:20 +02:00
										 |  |  |     sc->run_index = run_index; | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-09 23:35:44 +01:00
										 |  |  | static void RENAME(load_rgb_frame)(FFV1Context *f, FFV1SliceContext *sc, | 
					
						
							|  |  |  |                                   const uint8_t *src[4], | 
					
						
							|  |  |  |                                   int w, int h, const int stride[4]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int x, y; | 
					
						
							|  |  |  |     int transparency = f->transparency; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-02 16:30:28 +02:00
										 |  |  |     for (int p = 0; p<3 + transparency; p++) | 
					
						
							|  |  |  |         memset(sc->fltmap[p], 0, 65536 * sizeof(**sc->fltmap)); | 
					
						
							| 
									
										
										
										
											2025-03-09 23:35:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (y = 0; y < h; y++) { | 
					
						
							|  |  |  |         for (x = 0; x < w; x++) { | 
					
						
							|  |  |  |             int b, g, r, av_uninit(a); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (sizeof(TYPE) == 4 || transparency) { | 
					
						
							|  |  |  |                 g = *((const uint16_t *)(src[0] + x*2 + stride[0]*y)); | 
					
						
							|  |  |  |                 b = *((const uint16_t *)(src[1] + x*2 + stride[1]*y)); | 
					
						
							|  |  |  |                 r = *((const uint16_t *)(src[2] + x*2 + stride[2]*y)); | 
					
						
							|  |  |  |                 if (transparency) | 
					
						
							|  |  |  |                     a = *((const uint16_t *)(src[3] + x*2 + stride[3]*y)); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 b = *((const uint16_t *)(src[0] + x*2 + stride[0]*y)); | 
					
						
							|  |  |  |                 g = *((const uint16_t *)(src[1] + x*2 + stride[1]*y)); | 
					
						
							|  |  |  |                 r = *((const uint16_t *)(src[2] + x*2 + stride[2]*y)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-19 21:17:10 +01:00
										 |  |  |             sc->fltmap[0][g] = 1; | 
					
						
							|  |  |  |             sc->fltmap[1][b] = 1; | 
					
						
							|  |  |  |             sc->fltmap[2][r] = 1; | 
					
						
							| 
									
										
										
										
											2025-03-09 23:35:44 +01:00
										 |  |  |             if (transparency) | 
					
						
							|  |  |  |                 sc->fltmap[3][a] = 1; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  | static int RENAME(encode_rgb_frame)(FFV1Context *f, FFV1SliceContext *sc, | 
					
						
							| 
									
										
										
										
											2024-07-07 19:46:20 +02:00
										 |  |  |                                     const uint8_t *src[4], | 
					
						
							| 
									
										
										
										
											2025-03-09 23:33:48 +01:00
										 |  |  |                                     int w, int h, const int stride[4], int ac) | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     int x, y, p, i; | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  |     const int ring_size = f->context_model ? 3 : 2; | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |     TYPE *sample[4][3]; | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  |     const int pass1 = !!(f->avctx->flags & AV_CODEC_FLAG_PASS1); | 
					
						
							|  |  |  |     int lbd    = f->bits_per_raw_sample <= 8; | 
					
						
							| 
									
										
										
										
											2016-08-16 23:06:02 +02:00
										 |  |  |     int packed = !src[1]; | 
					
						
							| 
									
										
										
										
											2025-04-02 19:39:10 +02:00
										 |  |  |     int bits[4], offset; | 
					
						
							| 
									
										
										
										
											2024-07-08 13:11:52 +02:00
										 |  |  |     int transparency = f->transparency; | 
					
						
							| 
									
										
										
										
											2018-02-01 13:11:53 +01:00
										 |  |  |     int packed_size = (3 + transparency)*2; | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-02 19:39:10 +02:00
										 |  |  |     ff_ffv1_compute_bits_per_plane(f, sc, bits, &offset, NULL, f->bits_per_raw_sample); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-07 19:46:20 +02:00
										 |  |  |     sc->run_index = 0; | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												avcodec/ffv1enc: Use dummies to avoid UB pointer arithmetic
Fixes the following FATE-tests when run under Clang-UBSan:
ffmpeg-loopback-decoding, lavf-mxf_ffv1,
vsynth{1,2,3,_lena}-ffv1-v{0,2}, vsynth1-ffv{1,2,3,_lena},
vsynth{1,2,3,_lena}-ffv1-v3-yuv{420p,422p10,444p16}
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
											
										 
											2025-06-22 23:25:34 +02:00
										 |  |  |     for (int p = 0; p < MAX_PLANES; ++p) | 
					
						
							|  |  |  |         sample[p][2] = RENAME(sc->sample_buffer); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-07 19:46:20 +02:00
										 |  |  |     memset(RENAME(sc->sample_buffer), 0, ring_size * MAX_PLANES * | 
					
						
							|  |  |  |            (w + 6) * sizeof(*RENAME(sc->sample_buffer))); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (y = 0; y < h; y++) { | 
					
						
							|  |  |  |         for (i = 0; i < ring_size; i++) | 
					
						
							|  |  |  |             for (p = 0; p < MAX_PLANES; p++) | 
					
						
							| 
									
										
										
										
											2024-07-07 19:46:20 +02:00
										 |  |  |                 sample[p][i]= RENAME(sc->sample_buffer) + p*ring_size*(w+6) + ((h+i-y)%ring_size)*(w+6) + 3; | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         for (x = 0; x < w; x++) { | 
					
						
							|  |  |  |             int b, g, r, av_uninit(a); | 
					
						
							|  |  |  |             if (lbd) { | 
					
						
							|  |  |  |                 unsigned v = *((const uint32_t*)(src[0] + x*4 + stride[0]*y)); | 
					
						
							|  |  |  |                 b =  v        & 0xFF; | 
					
						
							|  |  |  |                 g = (v >>  8) & 0xFF; | 
					
						
							|  |  |  |                 r = (v >> 16) & 0xFF; | 
					
						
							|  |  |  |                 a =  v >> 24; | 
					
						
							| 
									
										
										
										
											2016-08-16 23:06:02 +02:00
										 |  |  |             } else if (packed) { | 
					
						
							| 
									
										
										
										
											2018-02-01 13:11:53 +01:00
										 |  |  |                 const uint16_t *p = ((const uint16_t*)(src[0] + x*packed_size + stride[0]*y)); | 
					
						
							| 
									
										
										
										
											2016-08-16 23:06:02 +02:00
										 |  |  |                 r = p[0]; | 
					
						
							|  |  |  |                 g = p[1]; | 
					
						
							|  |  |  |                 b = p[2]; | 
					
						
							| 
									
										
										
										
											2018-02-01 13:11:53 +01:00
										 |  |  |                 if (transparency) | 
					
						
							|  |  |  |                   a = p[3]; | 
					
						
							| 
									
										
										
										
											2018-02-14 08:39:15 +01:00
										 |  |  |             } else if (sizeof(TYPE) == 4 || transparency) { | 
					
						
							| 
									
										
										
										
											2016-08-16 23:04:00 +02:00
										 |  |  |                 g = *((const uint16_t *)(src[0] + x*2 + stride[0]*y)); | 
					
						
							|  |  |  |                 b = *((const uint16_t *)(src[1] + x*2 + stride[1]*y)); | 
					
						
							|  |  |  |                 r = *((const uint16_t *)(src[2] + x*2 + stride[2]*y)); | 
					
						
							| 
									
										
										
										
											2018-02-01 13:11:53 +01:00
										 |  |  |                 if (transparency) | 
					
						
							|  |  |  |                     a = *((const uint16_t *)(src[3] + x*2 + stride[3]*y)); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 b = *((const uint16_t *)(src[0] + x*2 + stride[0]*y)); | 
					
						
							|  |  |  |                 g = *((const uint16_t *)(src[1] + x*2 + stride[1]*y)); | 
					
						
							|  |  |  |                 r = *((const uint16_t *)(src[2] + x*2 + stride[2]*y)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-18 21:51:27 +01:00
										 |  |  |             if (sc->remap) { | 
					
						
							| 
									
										
										
										
											2025-03-19 21:17:10 +01:00
										 |  |  |                 g = sc->fltmap[0][g]; | 
					
						
							|  |  |  |                 b = sc->fltmap[1][b]; | 
					
						
							|  |  |  |                 r = sc->fltmap[2][r]; | 
					
						
							| 
									
										
										
										
											2025-01-18 19:30:48 +01:00
										 |  |  |                 if (transparency) | 
					
						
							|  |  |  |                     a = sc->fltmap[3][a]; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-08 16:11:25 +02:00
										 |  |  |             if (sc->slice_coding_mode != 1) { | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |                 b -= g; | 
					
						
							|  |  |  |                 r -= g; | 
					
						
							| 
									
										
										
										
											2024-07-08 16:11:25 +02:00
										 |  |  |                 g += (b * sc->slice_rct_by_coef + r * sc->slice_rct_ry_coef) >> 2; | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |                 b += offset; | 
					
						
							|  |  |  |                 r += offset; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             sample[0][0][x] = g; | 
					
						
							|  |  |  |             sample[1][0][x] = b; | 
					
						
							|  |  |  |             sample[2][0][x] = r; | 
					
						
							|  |  |  |             sample[3][0][x] = a; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-02-01 13:11:53 +01:00
										 |  |  |         for (p = 0; p < 3 + transparency; p++) { | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |             int ret; | 
					
						
							|  |  |  |             sample[p][0][-1] = sample[p][1][0  ]; | 
					
						
							|  |  |  |             sample[p][1][ w] = sample[p][1][w-1]; | 
					
						
							| 
									
										
										
										
											2025-04-02 19:39:10 +02:00
										 |  |  |             if (bits[p] == 9) | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  |                 ret = RENAME(encode_line)(f, sc, f->avctx, w, sample[p], (p + 1) / 2, 9, ac, pass1); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |             else | 
					
						
							| 
									
										
										
										
											2024-07-10 17:25:54 +02:00
										 |  |  |                 ret = RENAME(encode_line)(f, sc, f->avctx, w, sample[p], (p + 1) / 2, | 
					
						
							| 
									
										
										
										
											2025-04-02 19:39:10 +02:00
										 |  |  |                                           bits[p], ac, pass1); | 
					
						
							| 
									
										
										
										
											2016-08-07 23:37:17 +02:00
										 |  |  |             if (ret < 0) | 
					
						
							|  |  |  |                 return ret; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } |