aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-05-08 11:33:57 -0300
committerJames Almer <jamrial@gmail.com>2017-05-08 11:33:57 -0300
commit2cb656ad1197224470889a76d6b3d0bcb8cb0f34 (patch)
treeed9932b0990748f84594264ad2883bfcdb56ad57
parent74fee9760f7a9215c502ec1fa0c67ea2636b529c (diff)
downloadffmpeg-2cb656ad1197224470889a76d6b3d0bcb8cb0f34.tar.gz
avcodec/mjpegenc: move ff_mjpeg_encode_picture_frame to mjpegenc_common
Fixes compilation of ljpeg encoder if mjpeg and amv encoders are disabled
-rw-r--r--libavcodec/ljpegenc.c1
-rw-r--r--libavcodec/mjpegenc.c48
-rw-r--r--libavcodec/mjpegenc.h1
-rw-r--r--libavcodec/mjpegenc_common.c48
-rw-r--r--libavcodec/mjpegenc_common.h1
5 files changed, 49 insertions, 50 deletions
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index afaab05568..924d2e2fff 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -40,7 +40,6 @@
#include "jpegtables.h"
#include "mjpegenc_common.h"
#include "mjpeg.h"
-#include "mjpegenc.h"
typedef struct LJpegEncContext {
AVClass *class;
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 03c3d0ab13..ee77cde8cb 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -130,54 +130,6 @@ av_cold void ff_mjpeg_encode_close(MpegEncContext *s)
}
/**
- * Encodes and outputs the entire frame in the JPEG format.
- *
- * @param s The MpegEncContext.
- */
-void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
-{
- int i, nbits, code, table_id;
- MJpegContext *m = s->mjpeg_ctx;
- uint8_t *huff_size[4] = {m->huff_size_dc_luminance,
- m->huff_size_dc_chrominance,
- m->huff_size_ac_luminance,
- m->huff_size_ac_chrominance};
- uint16_t *huff_code[4] = {m->huff_code_dc_luminance,
- m->huff_code_dc_chrominance,
- m->huff_code_ac_luminance,
- m->huff_code_ac_chrominance};
- size_t total_bits = 0;
- size_t bytes_needed;
-
- s->header_bits = get_bits_diff(s);
- // Estimate the total size first
- for (i = 0; i < m->huff_ncode; i++) {
- table_id = m->huff_buffer[i].table_id;
- code = m->huff_buffer[i].code;
- nbits = code & 0xf;
-
- total_bits += huff_size[table_id][code] + nbits;
- }
-
- bytes_needed = (total_bits + 7) / 8;
- ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
-
- for (i = 0; i < m->huff_ncode; i++) {
- table_id = m->huff_buffer[i].table_id;
- code = m->huff_buffer[i].code;
- nbits = code & 0xf;
-
- put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]);
- if (nbits != 0) {
- put_sbits(&s->pb, nbits, m->huff_buffer[i].mant);
- }
- }
-
- m->huff_ncode = 0;
- s->i_tex_bits = get_bits_diff(s);
-}
-
-/**
* Add code and table_id to the JPEG buffer.
*
* @param s The MJpegContext which contains the JPEG buffer.
diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h
index 3dd1ba65ca..d7ddc35ef5 100644
--- a/libavcodec/mjpegenc.h
+++ b/libavcodec/mjpegenc.h
@@ -105,7 +105,6 @@ static inline void put_marker(PutBitContext *p, enum JpegMarker code)
}
int ff_mjpeg_encode_init(MpegEncContext *s);
-void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
void ff_mjpeg_encode_close(MpegEncContext *s);
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 6d9c982726..31868c9bed 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -359,6 +359,54 @@ end:
}
}
+/**
+ * Encodes and outputs the entire frame in the JPEG format.
+ *
+ * @param s The MpegEncContext.
+ */
+void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
+{
+ int i, nbits, code, table_id;
+ MJpegContext *m = s->mjpeg_ctx;
+ uint8_t *huff_size[4] = {m->huff_size_dc_luminance,
+ m->huff_size_dc_chrominance,
+ m->huff_size_ac_luminance,
+ m->huff_size_ac_chrominance};
+ uint16_t *huff_code[4] = {m->huff_code_dc_luminance,
+ m->huff_code_dc_chrominance,
+ m->huff_code_ac_luminance,
+ m->huff_code_ac_chrominance};
+ size_t total_bits = 0;
+ size_t bytes_needed;
+
+ s->header_bits = get_bits_diff(s);
+ // Estimate the total size first
+ for (i = 0; i < m->huff_ncode; i++) {
+ table_id = m->huff_buffer[i].table_id;
+ code = m->huff_buffer[i].code;
+ nbits = code & 0xf;
+
+ total_bits += huff_size[table_id][code] + nbits;
+ }
+
+ bytes_needed = (total_bits + 7) / 8;
+ ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
+
+ for (i = 0; i < m->huff_ncode; i++) {
+ table_id = m->huff_buffer[i].table_id;
+ code = m->huff_buffer[i].code;
+ nbits = code & 0xf;
+
+ put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]);
+ if (nbits != 0) {
+ put_sbits(&s->pb, nbits, m->huff_buffer[i].mant);
+ }
+ }
+
+ m->huff_ncode = 0;
+ s->i_tex_bits = get_bits_diff(s);
+}
+
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
{
int size;
diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h
index d9a565dfa9..e8698d18c6 100644
--- a/libavcodec/mjpegenc_common.h
+++ b/libavcodec/mjpegenc_common.h
@@ -32,6 +32,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
ScanTable *intra_scantable, int pred,
uint16_t luma_intra_matrix[64],
uint16_t chroma_intra_matrix[64]);
+void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
int ff_mjpeg_encode_stuffing(MpegEncContext *s);