Re: [FFmpeg-devel] [PATCH v2 8/8] aacenc: implement Intensity Stereo encoding support
On Thu, Jul 2, 2015 at 3:13 PM, Rostislav Pehlivanov wrote: > This commit implements intensity stereo coding support to the native aac > encoder. This is a way to increase the efficiency of the encoder by zeroing > the right channel's spectral coefficients (in a channel pair) and rederiving > them in the decoder using information from the scalefactor indices of special > band types. This commit confomrs to the official ISO 13818-7 specifications, > although due to their ambiguity certain deviations have been taken to ensure > maximum sound quality. This commit has been extensively tested and has shown > to not result in audiable audio artifacts unless in extreme cases. This > commit also adds an option, aac_is, which has the value of 0 by default. > Intensity Stereo is part of the scalable aac profile and is thus non-default. > > The way IS coding works is that it rederives the right channel's spectral > coefficients from the left channel via the scalefactor index values left in > the right channel. Since an entire band's spectral coefficients do not need > to be coded, the encoder's efficiency jumps up and it unzeroes some high > frequency values which it previously did not have enough bits to encode. That > way less information is lost than the information lost by rederiving the > spectral coefficients with some error. This is why the filesize of files > encoded with IS do not decrease significantly. Users wishing that IS coding > should reduce filesize are expected to reduce their encoding bitrates > appropriately. > > This is V2 of the commit. The old version did not mark ms_mask as 0 since M/S > and IS coding are incompactible, which resulted in distortions with M/S > coding enabled. This version also improves phase detection by measuring it > for every spectral coefficient in the band and using a simple majority rule > to determine whether the coefficients are in or out of phase. Also, the > energy values per spectral coefficient were changed as to reflect the > official specifications. This one also looks identical to a WIP I thoroughly tested, so I believe this means the whole set is good to be pushed, if a committer agrees. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 7/8] aacenc: add support for coding of IS spectral coefficients
On Thu, Jul 2, 2015 at 3:13 PM, Rostislav Pehlivanov wrote: > This commit adds support for the coding of intensity stereo spectral > coefficients. It also fixes the Mid/Side coding of band_types higher than > RESERVED_BT (M/S must not be applied to their spectral coefficients, but > marking M/S as present in encode_ms_info() is okay). Much of the changes here > were taken from the decoder and inverted. This commit does not change the > functionality of the decoder as the previous patch in this series zeroes > ms_mask and is_mask. > > Reviewed-by: Claudio Freire Indeed, LGTM ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 6/8] aaccoder: add a new perceptual noise substitution implementation
On Thu, Jul 2, 2015 at 3:13 PM, Rostislav Pehlivanov wrote: > This commit finalizes the PNS implementation previously added to the encoder > by moving it to a seperate function search_for_pns() and thus making it > coder-generic. This new implementation makes use of the spread field of the > psy bands and the lambda quality feedback paremeter. The spread of the > spectrum in a band prevents PNS from being used excessively and thus preserve > more phase information in high frequencies. The lambda parameter allows the > number of PNS-marked bands to vary based on the lambda parameter and the > amount of bits available, making better choices on which bands are to be > marked as noise. Comparisons with the previous PNS implementation can be > found here: https://trac.ffmpeg.org/attachment/wiki/Encode/AAC/ > > This is V2 of the patch, the changes from the previous version being that > this version uses the new band->spread metric from aacpsy and normalizes the > energy using the group size. These changes were suggested by Claudio Freire > on the mailing list. Another change is the use of lambda to alter the > frequency threshold. This change makes the actual threshold frequencies vary > between +-2Khz of what's specified, depending on frame encoding performance. LGTM. I probably should mention I already thoroughly tested a WIP version of the patch (which looks identical). This depends on #5, which is also good if it's pushed at the same time as other patches in the set (I already tested them as a whole). To push #5 in isolation I would have to test it a bit, to see it doesn't break anything. In any case it's not likely to break anything, but better safe than sorry. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 3/8] aaccoder: fix M/S coding
On Thu, Jul 2, 2015 at 3:13 PM, Rostislav Pehlivanov wrote: > There were some mistakes in the code for M/S stereo, this commit fixes them. > The start variable was not being reset for every window and every access to > the coefficients was incorrect as well. This fixes that by properly > addressing the coefficients using both windows and setting the start on every > window to zero. > --- > libavcodec/aaccoder.c | 15 --- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c > index 3fcc8b4..33cbe7b 100644 > --- a/libavcodec/aaccoder.c > +++ b/libavcodec/aaccoder.c > @@ -1143,6 +1143,7 @@ static void search_for_ms(AACEncContext *s, > ChannelElement *cpe, > if (!cpe->common_window) > return; > for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) { > +start = 0; > for (g = 0; g < sce0->ics.num_swb; g++) { > if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) { > float dist1 = 0.0f, dist2 = 0.0f; > @@ -1152,22 +1153,22 @@ static void search_for_ms(AACEncContext *s, > ChannelElement *cpe, > float minthr = FFMIN(band0->threshold, band1->threshold); > float maxthr = FFMAX(band0->threshold, band1->threshold); > for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { > -M[i] = (sce0->pcoeffs[start+w2*128+i] > - + sce1->pcoeffs[start+w2*128+i]) * 0.5; > +M[i] = (sce0->pcoeffs[start+(w+w2)*128+i] > + + sce1->pcoeffs[start+(w+w2)*128+i]) * 0.5; > S[i] = M[i] > - - sce1->pcoeffs[start+w2*128+i]; > + - sce1->pcoeffs[start+(w+w2)*128+i]; > } > -abs_pow34_v(L34, sce0->coeffs+start+w2*128, > sce0->ics.swb_sizes[g]); > -abs_pow34_v(R34, sce1->coeffs+start+w2*128, > sce0->ics.swb_sizes[g]); > +abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, > sce0->ics.swb_sizes[g]); > +abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, > sce0->ics.swb_sizes[g]); > abs_pow34_v(M34, M, > sce0->ics.swb_sizes[g]); > abs_pow34_v(S34, S, > sce0->ics.swb_sizes[g]); > -dist1 += quantize_band_cost(s, sce0->coeffs + start + > w2*128, > +dist1 += quantize_band_cost(s, sce0->coeffs + start + > (w+w2)*128, > L34, > sce0->ics.swb_sizes[g], > sce0->sf_idx[(w+w2)*16+g], > sce0->band_type[(w+w2)*16+g], > lambda / band0->threshold, > INFINITY, NULL); > -dist1 += quantize_band_cost(s, sce1->coeffs + start + > w2*128, > +dist1 += quantize_band_cost(s, sce1->coeffs + start + > (w+w2)*128, > R34, > sce1->ics.swb_sizes[g], > sce1->sf_idx[(w+w2)*16+g], LGTM. Though I should probably mention that this patch shouldn't make any difference in the current state of search_for_ms. Unless there's an error somewhere (which is common in my experience with the aac encoder, so the proposed code is more robust in that regard and should be pushed), the current code will result in the same behavior exactly. However, that's not always the case in other cases with the same coding pattern is used, usually in search_for_X functions, where start is used to compute the frequency that corresponds to a particular coefficient. In those uses, if start isn't based at 0 for any given window, the frequency will be wrongly computed. So I'd push this patch if only to keep things consistent, and to avoid similar errors in the future (I've corrected tons of instances of this in #2686). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 4/8] aacenc: reset marked IS and M/S bands upon frame encoding
On Thu, Jul 2, 2015 at 3:13 PM, Rostislav Pehlivanov wrote: > This commit resets any bands marked as M/S or IS upon encoding a frame. This > is needed because the arrays may contain some residual information upon > allocation on startup and because there isn't any mechanism to reset the > arrays once the frame has been encoded. > --- > libavcodec/aacenc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c > index 3a512ff..05a8162 100644 > --- a/libavcodec/aacenc.c > +++ b/libavcodec/aacenc.c > @@ -617,6 +617,8 @@ static int aac_encode_frame(AVCodecContext *avctx, > AVPacket *avpkt, > tag = s->chan_map[i+1]; > chans= tag == TYPE_CPE ? 2 : 1; > cpe = &s->cpe[i]; > +memset(cpe->is_mask, 0, sizeof(cpe->is_mask)); > +memset(cpe->ms_mask, 0, sizeof(cpe->ms_mask)); > put_bits(&s->pb, 3, tag); > put_bits(&s->pb, 4, chan_el_counter[tag]++); > for (ch = 0; ch < chans; ch++) Looks good and necessary ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 1/8] aacpsy: use a different metric for the spread of a band
On Thu, Jul 2, 2015 at 3:13 PM, Rostislav Pehlivanov wrote: > This commit modifies 02dbed6 to use band->active_lines to better gauge how > much information is contained within a single band and thus allow the > perceptual noise subsitution to more accurately determine which bands to code > as noise. The spread[w+g] used before this patch behaved more like a low-pass > filter for PNS band_types, which could mistakingly mark some low frequency > bands as noise. > > Reviewed-by: Claudio Freire > --- > libavcodec/aacpsy.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c > index 78232d4..b16f6b9 100644 > --- a/libavcodec/aacpsy.c > +++ b/libavcodec/aacpsy.c > @@ -787,7 +787,7 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, > int channel, > > psy_band->threshold = band->thr; > psy_band->energy= band->energy; > -psy_band->spread= spread_en[w+g]; > +psy_band->spread= band->active_lines * 2.0f / band_sizes[g]; > } > } Can't say much since I proposed it myself, so... LGTM ;-) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [FFmpeg-cvslog] aacenc: add support for coding of intensity stereo scalefactor indices
On Wed, Jul 1, 2015 at 2:02 PM, James Almer wrote: >> ffmpeg | branch: master | Rostislav Pehlivanov | >> Fri Jun 26 21:16:34 2015 +0100| [7c10b87b5744179f16411f5981e96738021ec7ca] | >> committer: Michael Niedermayer >> >> aacenc: add support for coding of intensity stereo scalefactor indices >> >> This commit adds support for the coding of intensity stereo scalefactor >> indices. >> It does not do any marking of such bands and as such does no functional >> changes >> to the encoder. It removes any old twoloop specific code for PNS and moves it >> into a seperate function which handles setting of scalefactor indices for >> PNS and IS bands. >> >> Reviewed-by: Claudio Freire >> Signed-off-by: Michael Niedermayer >> >> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c10b87b5744179f16411f5981e96738021ec7ca >> --- >> >> libavcodec/aaccoder.c | 37 + >> libavcodec/aacenc.c |6 +- >> 2 files changed, 42 insertions(+), 1 deletion(-) >> >> diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c >> index 2f99924..cd996b2 100644 >> --- a/libavcodec/aaccoder.c >> +++ b/libavcodec/aaccoder.c >> @@ -595,6 +595,43 @@ typedef struct TrellisPath { >> #define TRELLIS_STAGES 121 >> #define TRELLIS_STATES (SCALE_MAX_DIFF+1) >> >> +static void set_special_band_scalefactors(AACEncContext *s, >> SingleChannelElement *sce) > > This function is unused and being optimized out with a warning during > compilation. A further patch makes use of it, but this is moot since a new set of patches was pushed by Rostislav today, so lets take a look at those instead. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 7/9] lavf/http: increase range for listen, handle connection closing accordingly, add http_handshake and move handshake logic there
Signed-off-by: Stephan Holljes --- libavformat/http.c | 45 - 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index d9c3624..95065f5 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -129,7 +129,7 @@ static const AVOption options[] = { { "end_offset", "try to limit the request to bytes preceding this offset", OFFSET(end_off), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, D }, { "method", "Override the HTTP method or set the expected HTTP method from a client", OFFSET(method), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "reconnect", "auto reconnect after disconnect before EOF", OFFSET(reconnect), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D }, -{ "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D | E }, +{ "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E }, { NULL } }; @@ -307,6 +307,8 @@ static void handle_http_errors(URLContext *h, int error) HTTPContext *s = h->priv_data; if (h->is_connected) { switch(error) { +case 0: +break; case AVERROR_HTTP_BAD_REQUEST: ffurl_write(s->hd, bad_request, strlen(bad_request)); break; @@ -317,15 +319,32 @@ static void handle_http_errors(URLContext *h, int error) } } +static int http_handshake(URLContext *c) { +int ret, err = 0, new_location; +HTTPContext *ch = c->priv_data; +URLContext *cl = ch->hd; +static const char header[] = "HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nTransfer-Encoding: chunked\r\n\r\n"; +if ((ret = ffurl_handshake(cl)) < 0) +return ret; +if ((err = http_read_header(c, &new_location)) < 0) +goto fail; +if ((ret = ffurl_write(cl, header, strlen(header))) < 0) +goto fail; +// Avoid returning a positive value from ffurl_write() +ret = ret > 0 ? 0 : ret; +fail: +handle_http_errors(c, err); +return ret; +} + static int http_listen(URLContext *h, const char *uri, int flags, AVDictionary **options) { HTTPContext *s = h->priv_data; int ret; -static const char header[] = "HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nTransfer-Encoding: chunked\r\n\r\n"; char hostname[1024], proto[10]; char lower_url[100]; const char *lower_proto = "tcp"; -int port, new_location; +int port; s->chunked_post = 1; av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); @@ -333,18 +352,16 @@ static int http_listen(URLContext *h, const char *uri, int flags, lower_proto = "tls"; ff_url_join(lower_url, sizeof(lower_url), lower_proto, NULL, hostname, port, NULL); -av_dict_set(options, "listen", "1", 0); +if ((ret = av_dict_set_int(options, "listen", s->listen, 0)) < 0) +goto fail; if ((ret = ffurl_open(&s->hd, lower_url, AVIO_FLAG_READ_WRITE, &h->interrupt_callback, options)) < 0) goto fail; -if ((ret = http_read_header(h, &new_location)) < 0) - goto fail; -if ((ret = ffurl_write(s->hd, header, strlen(header))) < 0) - goto fail; -return 0; - +if (s->listen == 1) { +// single client +ret = http_handshake(h); +} fail: -handle_http_errors(h, ret); av_dict_free(&s->chained_options); return ret; } @@ -1263,7 +1280,7 @@ static int http_shutdown(URLContext *h, int flags) /* signal end of chunked encoding if used */ if (((flags & AVIO_FLAG_WRITE) && s->chunked_post) || -((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) { +((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen == 1)) { ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); ret = ret > 0 ? 0 : ret; s->end_chunked_post = 1; @@ -1282,7 +1299,7 @@ static int http_close(URLContext *h) av_freep(&s->inflate_buffer); #endif /* CONFIG_ZLIB */ -if (!s->end_chunked_post) +if ((s->listen != 2 && !s->end_chunked_post)) /* Close the write direction by sending the end of chunked encoding. */ ret = http_shutdown(h, h->flags); @@ -1365,6 +1382,8 @@ HTTP_CLASS(http); URLProtocol ff_http_protocol = { .name= "http", .url_open2 = http_open, +.url_accept = http_accept, +.url_handshake = http_handshake, .url_read= http_read, .url_write = http_write, .url_seek= http_seek, -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 9/9] Add http multi-client example code
Signed-off-by: Stephan Holljes --- doc/examples/Makefile | 1 + doc/examples/http_multiclient.c | 101 2 files changed, 102 insertions(+) create mode 100644 doc/examples/http_multiclient.c diff --git a/doc/examples/Makefile b/doc/examples/Makefile index 9699f11..8c9501b 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -18,6 +18,7 @@ EXAMPLES= avio_list_dir \ extract_mvs\ filtering_video\ filtering_audio\ +http_multiclient \ metadata \ muxing \ remuxing \ diff --git a/doc/examples/http_multiclient.c b/doc/examples/http_multiclient.c new file mode 100644 index 000..fdecab4 --- /dev/null +++ b/doc/examples/http_multiclient.c @@ -0,0 +1,101 @@ +/* + * copyright (c) 2015 Stephan Holljes + * + * 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 + */ + +/** + * @file + * libavformat multi-client network API usage example. + * + * @example http_multiclient.c + * This example will serve a file without decoding or demuxing it over http. + * Multiple clients can connect and will receive the same file. + */ + +#include +#include + +int main(int argc, char **argv) +{ +AVDictionary *options = NULL; +AVIOContext *input = NULL, *client = NULL, *server = NULL; +const char *in_uri, *out_uri; +int ret, pid, n; +uint8_t buf[1024]; + +if (argc < 3) { +printf("usage: %s input http://hostname[:port]\n"; + "API example program to serve http to multiple clients.\n" + "The output format is guessed according to the input file extension.\n" + "\n", argv[0]); +return 1; +} + +in_uri = argv[1]; +out_uri = argv[2]; + +av_register_all(); +avformat_network_init(); + +if ((ret = av_dict_set(&options, "listen", "2", 0)) < 0) +goto end; +if ((ret = avio_open2(&server, out_uri, AVIO_FLAG_READ_WRITE, NULL, &options)) < 0) +goto end; +fprintf(stderr, "Entering main loop.\n"); +for(;;) { +if ((ret = avio_accept(server, &client)) < 0) +goto end; +fprintf(stderr, "Accepted client, forking process.\n"); +pid = fork(); +if (pid == 0) { +fprintf(stderr, "Opening input file.\n"); +if ((ret = avio_open2(&input, in_uri, AVIO_FLAG_READ, NULL, NULL)) < 0) +goto end; +fprintf(stderr, "In child.\n"); +avio_handshake(client); +fprintf(stderr, "Handshake performed.\n"); +for(;;) { +n = avio_read(input, buf, sizeof(buf)); +fprintf(stderr, "Read %d bytes from input.\n", n); +if (n <= 0) { +fprintf(stderr, "n is negative, abort.\n"); +break; +} +fprintf(stderr, "Writing %d bytes of data.\n", n); +avio_write(client, buf, n); +avio_flush(client); +} +fprintf(stderr, "Flushing client\n"); +avio_flush(client); +fprintf(stderr, "Closing client\n"); +avio_close(client); +break; +} +} + +end: +if (ret) +fprintf(stderr, "Some errors occured.\n"); +if (server) +avio_close(server); +if (input) +avio_close(input); +if (ret < 0 && ret != AVERROR_EOF) +return 1; +return 0; +} -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] GSoC update
On Wed, Jul 1, 2015 at 4:10 PM, Nicolas George wrote: > Le duodi 12 messidor, an CCXXIII, Stephan Holljes a écrit : >> This might be a stupid question, but how would I go about that? Just >> use open() and read() from stdio.h or are there structs that allow me >> to do that even more easily? > > You must use the avio family of function, not the OS functions directly. You > can have a look at tools/aviocat.c, it is rather simple and does a good > chunk of what your server needs to do per client. > >> From b0f0caa700b8cbd0352304de703d8191bf0ac922 Mon Sep 17 00:00:00 2001 >> From: Stephan Holljes >> Date: Tue, 30 Jun 2015 07:42:14 +0200 >> Subject: [PATCH 1/8] lavf/network: split ff_listen_bind into ff_listen and >> ff_accept >> >> Signed-off-by: Stephan Holljes >> --- >> libavformat/network.c | 27 +-- >> libavformat/network.h | 21 + >> 2 files changed, 42 insertions(+), 6 deletions(-) >> >> diff --git a/libavformat/network.c b/libavformat/network.c >> index 47ade8c..8d61746 100644 >> --- a/libavformat/network.c >> +++ b/libavformat/network.c >> @@ -187,12 +187,11 @@ int ff_socket(int af, int type, int proto) >> return fd; >> } >> >> -int ff_listen_bind(int fd, const struct sockaddr *addr, >> - socklen_t addrlen, int timeout, URLContext *h) >> +int ff_listen(int fd, const struct sockaddr *addr, >> + socklen_t addrlen) >> { >> int ret; >> int reuse = 1; >> -struct pollfd lp = { fd, POLLIN, 0 }; >> if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse))) { >> av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_REUSEADDR) failed\n"); >> } >> @@ -203,6 +202,13 @@ int ff_listen_bind(int fd, const struct sockaddr *addr, >> ret = listen(fd, 1); >> if (ret) >> return ff_neterrno(); >> +return ret; >> +} >> + >> +int ff_accept(int fd, int timeout, URLContext *h) >> +{ >> +int ret; >> +struct pollfd lp = { fd, POLLIN, 0 }; >> >> ret = ff_poll_interrupt(&lp, 1, timeout, &h->interrupt_callback); >> if (ret < 0) >> @@ -211,15 +217,24 @@ int ff_listen_bind(int fd, const struct sockaddr *addr, >> ret = accept(fd, NULL, NULL); >> if (ret < 0) >> return ff_neterrno(); >> - >> -closesocket(fd); >> - >> if (ff_socket_nonblock(ret, 1) < 0) >> av_log(NULL, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); >> >> return ret; >> } >> >> +int ff_listen_bind(int fd, const struct sockaddr *addr, >> + socklen_t addrlen, int timeout, URLContext *h) >> +{ >> +int ret; >> +if ((ret = ff_listen(fd, addr, addrlen)) < 0) >> +return ret; > >> +ret = ff_accept(fd, timeout, h); >> +closesocket(fd); >> +return ret; > > I believe you are slightly changing the behaviour here: in the old code, if > accept() fails, the server is not closed. > >> + >> +} >> + >> int ff_listen_connect(int fd, const struct sockaddr *addr, >>socklen_t addrlen, int timeout, URLContext *h, >>int will_try_next) >> diff --git a/libavformat/network.h b/libavformat/network.h >> index 86fb656..e684787 100644 >> --- a/libavformat/network.h >> +++ b/libavformat/network.h >> @@ -255,6 +255,27 @@ int ff_listen_bind(int fd, const struct sockaddr *addr, >> URLContext *h); >> >> /** > >> + * Bind to a file descriptor and return a listening socket without >> accepting connections. >> + * @param fd First argument of bind(). >> + * @param addrSecond argument of bind(). >> + * @param addrlen Third argument of bind(). >> + * @returnA blocking file descriptor on success >> + *or an AVERROR on failure. > > I believe the summary and @return statements are wrong: the new code always > returns 0 for success, which is fine. > >> + */ >> +int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen); >> + >> +/** >> + * Poll for a single connection on the passed file descriptor. >> + * @param fd The listening socket file descriptor. >> + * @param timeout Polling timeout in milliseconds. >> + * @param h URLContext providing interrupt check >> + *callback and logging context. >> + * @returnA non-blocking file descriptor on success >> + *or an AVERROR on failure. >> + */ >> +int ff_accept(int fd, int timeout, URLContext *h); >> + >> +/** >> * Connect to a file descriptor and poll for result. >> * >> * @param fd First argument of connect(), >> -- >> 2.1.0 >> > >> From 330c0eedaede961e52a4a4d93b2211156bc15a69 Mon Sep 17 00:00:00 2001 >> From: Stephan Holljes >> Date: Tue, 30 Jun 2015 08:16:37 +0200 >> Subject: [PATCH 2/8] lavf/avio: add ffurl_accept and ffurl_handshake >> >> Signed-off-by: Stephan Holljes >> --- >> libavformat/avio.c | 17 + >> libavformat/url.h | 18 ++ >> 2 files changed, 35 insertions(+) >> >> diff --git a/libavformat/avio.c b/
[FFmpeg-devel] [PATCH 4/9] lavf/tcp: add tcp_accept
Signed-off-by: Stephan Holljes --- libavformat/tcp.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/libavformat/tcp.c b/libavformat/tcp.c index f24cad2..875da50 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" +#include "libavutil/avassert.h" #include "libavutil/parseutils.h" #include "libavutil/opt.h" #include "libavutil/time.h" @@ -163,6 +164,23 @@ static int tcp_open(URLContext *h, const char *uri, int flags) return ret; } +static int tcp_accept(URLContext *s, URLContext **c) +{ +TCPContext *sc = s->priv_data; +TCPContext *cc; +int ret; +av_assert0(sc->listen); +if ((ret = ffurl_alloc(c, s->filename, AVIO_FLAG_READ_WRITE, &s->interrupt_callback)) < 0) +return ret; +cc = (*c)->priv_data; +ret = accept(sc->fd, NULL, NULL); +if (ret < 0) { +return ff_neterrno(); +} +cc->fd = ret; +return 0; +} + static int tcp_read(URLContext *h, uint8_t *buf, int size) { TCPContext *s = h->priv_data; @@ -223,6 +241,7 @@ static int tcp_get_file_handle(URLContext *h) URLProtocol ff_tcp_protocol = { .name= "tcp", .url_open= tcp_open, +.url_accept = tcp_accept, .url_read= tcp_read, .url_write = tcp_write, .url_close = tcp_close, -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 5/9] lavf/tcp: increase range for listen and call the underlying socket operations accordingly
Signed-off-by: Stephan Holljes --- libavformat/tcp.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 875da50..91c70d4 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -45,7 +45,7 @@ typedef struct TCPContext { #define D AV_OPT_FLAG_DECODING_PARAM #define E AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "listen", "Listen for incoming connections", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = D|E }, +{ "listen", "Listen for incoming connections", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, .flags = D|E }, { "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "listen_timeout", "Connection awaiting timeout (in milliseconds)", OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { NULL } @@ -126,12 +126,18 @@ static int tcp_open(URLContext *h, const char *uri, int flags) goto fail; } -if (s->listen) { -if ((ret = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, - s->listen_timeout, h)) < 0) { +if (s->listen == 2) { +// multi-client +if ((ret = ff_listen(fd, cur_ai->ai_addr, cur_ai->ai_addrlen)) < 0) { +goto fail1; +} +} else if (s->listen == 1) { +// single client +if ((fd = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, + s->listen_timeout, h)) < 0) { +ret = fd; goto fail1; } -fd = ret; } else { if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, s->open_timeout / 1000, h, !!cur_ai->ai_next)) < 0) { -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 6/9] lavf/http: add http_accept
Signed-off-by: Stephan Holljes --- libavformat/http.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index 676bfd5..d9c3624 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -25,6 +25,7 @@ #include #endif /* CONFIG_ZLIB */ +#include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/opt.h" @@ -382,6 +383,24 @@ static int http_open(URLContext *h, const char *uri, int flags, return ret; } +static int http_accept(URLContext *s, URLContext **c) +{ +int ret; +HTTPContext *sc = s->priv_data; +HTTPContext *cc; +URLContext *sl = sc->hd; +URLContext *cl; +av_assert0(sc->listen); +if ((ret = ffurl_alloc(c, s->filename, AVIO_FLAG_WRITE, &sl->interrupt_callback)) < 0) +goto fail; +cc = (*c)->priv_data; +if ((ret = ffurl_accept(sl, &cl)) < 0) +goto fail; +cc->hd = cl; +fail: +return ret; +} + static int http_getc(HTTPContext *s) { int len; -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 8/9] doc/protocols: document experimental mutli-client api
Signed-off-by: Stephan Holljes --- doc/protocols.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/protocols.texi b/doc/protocols.texi index 453dbcf..39a132a 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -292,6 +292,8 @@ autodetection in the future. If set to 1 enables experimental HTTP server. This can be used to send data when used as an output option, or read data from a client with HTTP POST when used as an input option. +If set to 2 enables experimental mutli-client HTTP server. This is not yet implemented +in ffmpeg.c or ffserver.c and thus must not be used as a command line option. @example # Server side (sending): ffmpeg -i somefile.ogg -c copy -listen 1 -f ogg http://@var{server}:@var{port} -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/9] lavf/avio: add avio_accept and avio_handshake
Signed-off-by: Stephan Holljes --- libavformat/avio.h| 16 libavformat/aviobuf.c | 17 + 2 files changed, 33 insertions(+) diff --git a/libavformat/avio.h b/libavformat/avio.h index d3d9bbd..b7a4fa8 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -648,4 +648,20 @@ struct AVBPrint; */ int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size); +/** + * Accept and allocate a client context on a server context. + * @param s the server context + * @param c the client context + * @return >= 0 on success or a negative value corresponding + * to an AVERROR on failure + */ +int avio_accept(AVIOContext *s, AVIOContext **c); + +/** + * Perform a protocol dependent handshake + * @param c the client context to perform the handshake on + * @return >= 0 on success or a negative value corresponding + * to an AVERROR on failure + */ +int avio_handshake(AVIOContext *c); #endif /* AVFORMAT_AVIO_H */ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index ff85081..ce05c5d 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1021,6 +1021,23 @@ int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size) return 0; } +int avio_accept(AVIOContext *s, AVIOContext **c) +{ +int ret; +URLContext *sc = s->opaque; +URLContext *cc; +ret = ffurl_accept(sc, &cc); +if (ret < 0) +return ret; +return ffio_fdopen(c, cc); +} + +int avio_handshake(AVIOContext *c) +{ +URLContext *cc = c->opaque; +return ffurl_handshake(cc); +} + /* output in a dynamic buffer */ typedef struct DynBuffer { -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/9] lavf/avio: add ffurl_accept and ffurl_handshake
Signed-off-by: Stephan Holljes --- libavformat/avio.c | 19 +++ libavformat/url.h | 18 ++ 2 files changed, 37 insertions(+) diff --git a/libavformat/avio.c b/libavformat/avio.c index c188adc..1182336 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -211,6 +211,25 @@ int ffurl_connect(URLContext *uc, AVDictionary **options) return 0; } +int ffurl_accept(URLContext *s, URLContext **c) +{ +if (s->prot->url_accept) +return s->prot->url_accept(s, c); +return 0; +} + +int ffurl_handshake(URLContext *c) +{ +int ret; +if (c->prot->url_handshake) { +ret = c->prot->url_handshake(c); +if (ret) +return ret; +} +c->is_connected = 1; +return 0; +} + #define URL_SCHEME_CHARS\ "abcdefghijklmnopqrstuvwxyz"\ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"\ diff --git a/libavformat/url.h b/libavformat/url.h index 99a3201..d010a77 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -58,6 +58,8 @@ typedef struct URLProtocol { * for those nested protocols. */ int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options); +int (*url_accept)(URLContext *s, URLContext **c); +int (*url_handshake)(URLContext *c); /** * Read data from the protocol. @@ -140,6 +142,22 @@ int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options); /** + * Accept an URLContext c on an URLContext s + * @param s server context + * @param c client context + * @return >= 0 on success, ff_neterrno() on failure. + */ +int ffurl_accept(URLContext *s, URLContext **c); + +/** + * Perform a protocol handshake on the passed client context. + * @param c the client context + * @return >= 0 on success or a negative value corresponding + * to an AVERROR code on failure + */ +int ffurl_handshake(URLContext *c); + +/** * Read up to size bytes from the resource accessed by h, and store * the read bytes in buf. * -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/9] lavf/network: split ff_listen_bind into ff_listen and ff_accept
Signed-off-by: Stephan Holljes --- libavformat/network.c | 27 +-- libavformat/network.h | 20 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/libavformat/network.c b/libavformat/network.c index 47ade8c..7a326d2 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -187,12 +187,11 @@ int ff_socket(int af, int type, int proto) return fd; } -int ff_listen_bind(int fd, const struct sockaddr *addr, - socklen_t addrlen, int timeout, URLContext *h) +int ff_listen(int fd, const struct sockaddr *addr, + socklen_t addrlen) { int ret; int reuse = 1; -struct pollfd lp = { fd, POLLIN, 0 }; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse))) { av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_REUSEADDR) failed\n"); } @@ -203,6 +202,13 @@ int ff_listen_bind(int fd, const struct sockaddr *addr, ret = listen(fd, 1); if (ret) return ff_neterrno(); +return ret; +} + +int ff_accept(int fd, int timeout, URLContext *h) +{ +int ret; +struct pollfd lp = { fd, POLLIN, 0 }; ret = ff_poll_interrupt(&lp, 1, timeout, &h->interrupt_callback); if (ret < 0) @@ -211,15 +217,24 @@ int ff_listen_bind(int fd, const struct sockaddr *addr, ret = accept(fd, NULL, NULL); if (ret < 0) return ff_neterrno(); - -closesocket(fd); - if (ff_socket_nonblock(ret, 1) < 0) av_log(NULL, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); return ret; } +int ff_listen_bind(int fd, const struct sockaddr *addr, + socklen_t addrlen, int timeout, URLContext *h) +{ +int ret; +if ((ret = ff_listen(fd, addr, addrlen)) < 0) +return ret; +if ((ret = ff_accept(fd, timeout, h)) < 0) +return ret; +closesocket(fd); +return ret; +} + int ff_listen_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next) diff --git a/libavformat/network.h b/libavformat/network.h index 86fb656..f83c796 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -255,6 +255,26 @@ int ff_listen_bind(int fd, const struct sockaddr *addr, URLContext *h); /** + * Bind to a file descriptor to an address without accepting connections. + * @param fd First argument of bind(). + * @param addrSecond argument of bind(). + * @param addrlen Third argument of bind(). + * @return0 on success or an AVERROR on failure. + */ +int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen); + +/** + * Poll for a single connection on the passed file descriptor. + * @param fd The listening socket file descriptor. + * @param timeout Polling timeout in milliseconds. + * @param h URLContext providing interrupt check + *callback and logging context. + * @returnA non-blocking file descriptor on success + *or an AVERROR on failure. + */ +int ff_accept(int fd, int timeout, URLContext *h); + +/** * Connect to a file descriptor and poll for result. * * @param fd First argument of connect(), -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] webp: fix infinite loop in webp_decode_frame
On Fri, Jul 03, 2015 at 02:42:57AM +0200, Michael Niedermayer wrote: > On Thu, Jul 02, 2015 at 11:45:46PM +0200, Andreas Cadhalpun wrote: > > The loop always needs at least 8 bytes for chunk_type and chunk_size. > > If fewer are left, bytestream2_get_le32 just returns 0 without > > reading any bytes, leading to an infinite loop. > > > > Signed-off-by: Andreas Cadhalpun > > --- > > libavcodec/webp.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > LGTM applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] webp: fix infinite loop in webp_decode_frame
On Thu, Jul 02, 2015 at 11:45:46PM +0200, Andreas Cadhalpun wrote: > The loop always needs at least 8 bytes for chunk_type and chunk_size. > If fewer are left, bytestream2_get_le32 just returns 0 without > reading any bytes, leading to an infinite loop. > > Signed-off-by: Andreas Cadhalpun > --- > libavcodec/webp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) LGTM thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Freedom in capitalist society always remains about the same as it was in ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] fate/api-tests: Tests that need samples should only run if SAMPLES is set
This change fixes a bug where a test that required a sample was being included in the suite when SAMPLES was not set. It also improves the consistency of variable names relating to the API tests. --- tests/fate/api.mak | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/fate/api.mak b/tests/fate/api.mak index da50036..4a1ee81 100644 --- a/tests/fate/api.mak +++ b/tests/fate/api.mak @@ -4,12 +4,20 @@ fate-api-flac: CMD = run $(APITESTSDIR)/api-flac-test fate-api-flac: CMP = null fate-api-flac: REF = /dev/null -FATE_API_SAMPLES-LIBAVFORMAT-$(call DEMDEC, H264, H264) += fate-api-h264 +FATE_API_SAMPLES_LIBAVFORMAT-$(call DEMDEC, H264, H264) += fate-api-h264 fate-api-h264: $(APITESTSDIR)/api-h264-test$(EXESUF) fate-api-h264: CMD = run $(APITESTSDIR)/api-h264-test $(TARGET_SAMPLES)/h264-conformance/SVA_NL2_E.264 -FATE-$(CONFIG_AVCODEC) += $(FATE_API_LIBAVCODEC-yes) -FATE_API_SAMPLES-$(CONFIG_AVFORMAT) += $(FATE_API_SAMPLES-LIBAVFORMAT-yes) -FATE_SAMPLES_AVCONV += $(FATE_API_SAMPLES-yes) +FATE_API_SAMPLES-$(CONFIG_AVFORMAT) += $(FATE_API_SAMPLES_LIBAVFORMAT-yes) -fate-api: $(FATE_API_LIBAVCODEC-yes) $(FATE_API_SAMPLES-yes) +ifdef SAMPLES +FATE_API_SAMPLES += $(FATE_API_SAMPLES-yes) +endif + +FATE_API-$(CONFIG_AVCODEC) += $(FATE_API_LIBAVCODEC-yes) +FATE_API-$(CONFIG_AVFORMAT) += $(FATE_API_LIBAVFORMAT-yes) +FATE_API = $(FATE_API-yes) + +FATE-yes += $(FATE_API) $(FATE_API_SAMPLES) + +fate-api: $(FATE_API) $(FATE_API_SAMPLES) -- 2.4.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] api-seek-test: first version
On Thu, Jul 02, 2015 at 06:55:36PM +0300, Ludmila Glinskih wrote: > Works only with video stream. > --- > tests/api/Makefile| 1 + > tests/api/api-seek-test.c | 197 > ++ > tests/fate/api.mak| 4 + > tests/ref/fate/api-seek | 147 ++ > 4 files changed, 349 insertions(+) > create mode 100644 tests/api/api-seek-test.c > create mode 100644 tests/ref/fate/api-seek > > diff --git a/tests/api/Makefile b/tests/api/Makefile > index 704987e..59cbc7c 100644 > --- a/tests/api/Makefile > +++ b/tests/api/Makefile > @@ -1,5 +1,6 @@ > APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac > APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264 > +APITESTPROGS-yes += api-seek > APITESTPROGS += $(APITESTPROGS-yes) > > APITESTOBJS := $(APITESTOBJS:%=$(APITESTSDIR)%) > $(APITESTPROGS:%=$(APITESTSDIR)/%-test.o) > diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c > new file mode 100644 > index 000..9f8bad9 > --- /dev/null > +++ b/tests/api/api-seek-test.c > @@ -0,0 +1,197 @@ > +/* > + * Copyright (c) 2015 Ludmila Glinskih > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > copy > + * of this software and associated documentation files (the "Software"), to > deal > + * in the Software without restriction, including without limitation the > rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > + > +/** > + * Seek test. > + */ > + > +#include "libavutil/adler32.h" > +#include "libavcodec/avcodec.h" > +#include "libavformat/avformat.h" > +#include "libavutil/imgutils.h" > + > +static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream, > +AVCodecContext *ctx, AVFrame *fr, uint64_t > ts_start, uint64_t ts_end) > +{ > +int number_of_written_bytes; > +int got_frame = 0; > +int result; > +int end_of_stream = 0; > +int byte_buffer_size; > +uint8_t *byte_buffer; > +AVPacket pkt; > + > +byte_buffer_size = av_image_get_buffer_size(ctx->pix_fmt, ctx->width, > ctx->height, 16); > +byte_buffer = av_malloc(byte_buffer_size); > +if (!byte_buffer) { > +av_log(NULL, AV_LOG_ERROR, "Can't allocate buffer\n"); > +return AVERROR(ENOMEM); > +} > + > +result = av_seek_frame(fmt_ctx, video_stream, ts_start, AVSEEK_FLAG_ANY); > +printf("Seeking to %"PRId64", computing crc for frames with pts < > %"PRId64"\n", ts_start, ts_end); > +if (result < 0) { > +av_log(NULL, AV_LOG_ERROR, "Error in seeking\n"); > +return result; > +} > +avcodec_flush_buffers(ctx); > + > +av_init_packet(&pkt); > +do { > +if (!end_of_stream) > +if (av_read_frame(fmt_ctx, &pkt) < 0) > +end_of_stream = 1; > +if (end_of_stream) > +{ inconsistent placement of "{" [...] > diff --git a/tests/fate/api.mak b/tests/fate/api.mak > index da50036..005554d 100644 > --- a/tests/fate/api.mak > +++ b/tests/fate/api.mak > @@ -8,6 +8,10 @@ FATE_API_SAMPLES-LIBAVFORMAT-$(call DEMDEC, H264, H264) += > fate-api-h264 > fate-api-h264: $(APITESTSDIR)/api-h264-test$(EXESUF) > fate-api-h264: CMD = run $(APITESTSDIR)/api-h264-test > $(TARGET_SAMPLES)/h264-conformance/SVA_NL2_E.264 > > +FATE_API_SAMPLES-LIBAVFORMAT-$(call DEMDEC, H264, H264) += fate-api-seek > +fate-api-seek: $(APITESTSDIR)/api-seek-test$(EXESUF) > +fate-api-seek: CMD = run $(APITESTSDIR)/api-seek-test > $(TARGET_PATH)/tests/data/lavf/lavf.flv 0 720 this is missing a depandancy on the flv file used for testing so its possible that this file hasnt been generated. also maybe its easier to use a fate sample, instead of a generated file [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] snow: remove strange av_assert2
On Fri, Jul 03, 2015 at 12:31:31AM +0200, Andreas Cadhalpun wrote: > It asserts that the frame linesize is larger than 37, but it can be > smaller and decoding such frames works. Thus it is unclear what this > assert is good for. i think it was due to the layout of some temporary /scratch buffer maybe in the emulated_edge_mc() call in ff_snow_pred_block() but iam not sure as stride becomes too small its no longer possible to store some elements that is when they are larger The assert should possibly be made conditional on such too large blocks occuring when stride is too small [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] wmalosslessdec: avoid reading 0 bits with get_bits
On Fri, Jul 03, 2015 at 12:07:04AM +0200, Andreas Cadhalpun wrote: > Signed-off-by: Andreas Cadhalpun > --- > libavcodec/wmalosslessdec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) LGTM thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB What does censorship reveal? It reveals fear. -- Julian Assange signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] snow: remove strange av_assert2
It asserts that the frame linesize is larger than 37, but it can be smaller and decoding such frames works. Thus it is unclear what this assert is good for. Signed-off-by: Andreas Cadhalpun --- This av_assert2 can be triggered with: $ ffmpeg -f lavfi -i testsrc=s=32x32:d=0.1 -c snow snow.nut $ ffmpeg -i test.snow -f null /dev/null --- libavcodec/snow.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/snow.h b/libavcodec/snow.h index 95e07cd..3773028 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -347,8 +347,6 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer if(b_w<=0 || b_h<=0) return; -av_assert2(src_stride > 2*MB_SIZE + 5); - if(!sliced && offset_dst) dst += src_x + src_y*dst_stride; dst8+= src_x + src_y*src_stride; -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] wmalosslessdec: avoid reading 0 bits with get_bits
Signed-off-by: Andreas Cadhalpun --- libavcodec/wmalosslessdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 843ce90..8094db3 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -488,7 +488,7 @@ static int decode_cdlms(WmallDecodeCtx *s) if ((1 << cbits) < s->cdlms[c][i].scaling + 1) cbits++; -s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2; +s->cdlms[c][i].bitsend = (cbits ? get_bits(&s->gb, cbits) : 0) + 2; shift_l = 32 - s->cdlms[c][i].bitsend; shift_r = 32 - s->cdlms[c][i].scaling - 2; for (j = 0; j < s->cdlms[c][i].coefsend; j++) -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] wmalosslessdec: reset frame->nb_samples on packet loss
Otherwise a frame with non-zero nb_samples but without any data can be returned. Signed-off-by: Andreas Cadhalpun --- libavcodec/wmalosslessdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 8094db3..0c85c83 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -1005,6 +1005,7 @@ static int decode_frame(WmallDecodeCtx *s) if ((ret = ff_get_buffer(s->avctx, s->frame, 0)) < 0) { /* return an error if no frame could be decoded at all */ s->packet_loss = 1; +s->frame->nb_samples = 0; return ret; } for (i = 0; i < s->num_channels; i++) { -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] webp: fix infinite loop in webp_decode_frame
The loop always needs at least 8 bytes for chunk_type and chunk_size. If fewer are left, bytestream2_get_le32 just returns 0 without reading any bytes, leading to an infinite loop. Signed-off-by: Andreas Cadhalpun --- libavcodec/webp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 47e9e9e..723a847 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1387,7 +1387,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } av_dict_free(&s->exif_metadata); -while (bytestream2_get_bytes_left(&gb) > 0) { +while (bytestream2_get_bytes_left(&gb) > 8) { char chunk_str[5] = { 0 }; chunk_type = bytestream2_get_le32(&gb); -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] wavpack: limit extra_bits to 32 and use get_bits_long
On 02.07.2015 23:20, Paul B Mahol wrote: > On 7/2/15, Andreas Cadhalpun wrote: >> More than 32 bits can't be stored in an integer and get_bits should not >> be used with more than 25 bits. >> >> Signed-off-by: Andreas Cadhalpun >> --- >> libavcodec/wavpack.c | 8 ++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c >> index d91b66c..554367b 100644 >> --- a/libavcodec/wavpack.c >> +++ b/libavcodec/wavpack.c >> @@ -271,7 +271,7 @@ static inline int >> wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, >> >> if (s->got_extra_bits && >> get_bits_left(&s->gb_extra_bits) >= s->extra_bits) { >> -S |= get_bits(&s->gb_extra_bits, s->extra_bits); >> +S |= get_bits_long(&s->gb_extra_bits, s->extra_bits); >> *crc = *crc * 9 + (S & 0x) * 3 + ((unsigned)S >> 16); >> } >> } >> @@ -835,7 +835,11 @@ static int wavpack_decode_block(AVCodecContext *avctx, >> int block_no, >> continue; >> } >> bytestream2_get_buffer(&gb, val, 4); >> -if (val[0]) { >> +if (val[0] > 32) { >> +av_log(avctx, AV_LOG_ERROR, >> + "Invalid INT32INFO, extra_bits = %d (> 32)\n", >> val[0]); >> +continue; >> +} else if (val[0]) { >> s->extra_bits = val[0]; >> } else if (val[1]) { >> s->shift = val[1]; >> -- >> 2.1.4 >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > lgtm Pushed. Best regards, Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCHv3] avcodec: Add support for Closed Caption export in h264
On Thu, Jul 2, 2015 at 11:17 PM, Pavel Koshevoy wrote: > On Thu, Jul 2, 2015 at 12:18 PM, Kieran Kunhya > wrote: > >> --- >> libavcodec/h264.c | 11 +++ >> libavcodec/h264.h | 2 ++ >> libavcodec/h264_sei.c | 35 ++- >> 3 files changed, 47 insertions(+), 1 deletion(-) >> >> diff --git a/libavcodec/h264.c b/libavcodec/h264.c >> index 1cbd4cb..1569ec8 100644 >> --- a/libavcodec/h264.c >> +++ b/libavcodec/h264.c >> @@ -609,6 +609,8 @@ static int h264_init_context(AVCodecContext *avctx, >> H264Context *h) >> h->prev_frame_num= -1; >> h->sei_fpa.frame_packing_arrangement_cancel_flag = -1; >> h->has_afd = 0; >> +h->a53_caption_size = 0; >> +h->a53_caption = NULL; >> >> h->next_outputed_poc = INT_MIN; >> for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) >> @@ -879,6 +881,15 @@ static void decode_postinit(H264Context *h, int >> setup_finished) >> } >> } >> >> +if (h->a53_caption) { >> +AVFrameSideData *sd = >> +av_frame_new_side_data(cur->f, AV_FRAME_DATA_A53_CC, >> h->a53_caption_size); >> +if (sd) >> +memcpy(sd->data, h->a53_caption, h->a53_caption_size); >> +av_freep(&h->a53_caption); >> +h->a53_caption_size = 0; >> +} >> + >> cur->mmco_reset = h->mmco_reset; >> h->mmco_reset = 0; >> >> diff --git a/libavcodec/h264.h b/libavcodec/h264.h >> index 7565e03..3aef49f 100644 >> --- a/libavcodec/h264.h >> +++ b/libavcodec/h264.h >> @@ -784,6 +784,8 @@ typedef struct H264Context { >> uint8_t afd; >> int has_afd; >> >> +int a53_caption_size; >> +uint8_t *a53_caption; >> >> // Timestamp stuff >> int sei_buffering_period_present; ///< Buffering period SEI flag >> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c >> index b6ec5c7..5c6fcc0 100644 >> --- a/libavcodec/h264_sei.c >> +++ b/libavcodec/h264_sei.c >> @@ -111,7 +111,7 @@ static int decode_picture_timing(H264Context *h) >> static int decode_user_data_itu_t_t35(H264Context *h, int size) >> { >> uint32_t user_identifier; >> -int dtg_active_format; >> +int dtg_active_format, cc_count, user_data_type_code; >> >> if (size < 7) >> return -1; >> @@ -143,6 +143,39 @@ FF_ENABLE_DEPRECATION_WARNINGS >> skip_bits(&h->gb, 6); >> } >> break; >> +case 0x47413934: // "GA94" closed captions >> > > > Pardon my ignorance, but is this endian safe? 0x47413934 is "GA94" on > big-endian architectures, won't it be 0x34394147 on little-endian? > The way the value is read will always fill the variable with this exact value, no matter what the endianness of the underlying memory actually is. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: use AVFILTER_DEFINE_CLASS()
On 7/2/15, Michael Niedermayer wrote: > On Thu, Jul 02, 2015 at 09:52:02AM +, Paul B Mahol wrote: >> Signed-off-by: Paul B Mahol >> --- >> libavfilter/af_bs2b.c | 9 ++--- >> libavfilter/vf_cover_rect.c| 8 +--- >> libavfilter/vf_find_rect.c | 12 +++- >> libavfilter/vf_framepack.c | 9 ++--- >> libavfilter/vf_shuffleplanes.c | 7 +-- >> 5 files changed, 9 insertions(+), 36 deletions(-) > > LGTM > > thanks > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Democracy is the form of government in which you can choose your dictator > applied ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/vf_mpdecimate: remove packed formats
On 7/2/15, Paul B Mahol wrote: > Packed formats are not supported. > > Signed-off-by: Paul B Mahol > --- > libavfilter/vf_mpdecimate.c | 3 --- > 1 file changed, 3 deletions(-) > applied ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] wavpack: limit extra_bits to 32 and use get_bits_long
On 7/2/15, Andreas Cadhalpun wrote: > More than 32 bits can't be stored in an integer and get_bits should not > be used with more than 25 bits. > > Signed-off-by: Andreas Cadhalpun > --- > libavcodec/wavpack.c | 8 ++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c > index d91b66c..554367b 100644 > --- a/libavcodec/wavpack.c > +++ b/libavcodec/wavpack.c > @@ -271,7 +271,7 @@ static inline int > wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, > > if (s->got_extra_bits && > get_bits_left(&s->gb_extra_bits) >= s->extra_bits) { > -S |= get_bits(&s->gb_extra_bits, s->extra_bits); > +S |= get_bits_long(&s->gb_extra_bits, s->extra_bits); > *crc = *crc * 9 + (S & 0x) * 3 + ((unsigned)S >> 16); > } > } > @@ -835,7 +835,11 @@ static int wavpack_decode_block(AVCodecContext *avctx, > int block_no, > continue; > } > bytestream2_get_buffer(&gb, val, 4); > -if (val[0]) { > +if (val[0] > 32) { > +av_log(avctx, AV_LOG_ERROR, > + "Invalid INT32INFO, extra_bits = %d (> 32)\n", > val[0]); > +continue; > +} else if (val[0]) { > s->extra_bits = val[0]; > } else if (val[1]) { > s->shift = val[1]; > -- > 2.1.4 > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > lgtm ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCHv3] avcodec: Add support for Closed Caption export in h264
On Thu, Jul 2, 2015 at 12:18 PM, Kieran Kunhya wrote: > --- > libavcodec/h264.c | 11 +++ > libavcodec/h264.h | 2 ++ > libavcodec/h264_sei.c | 35 ++- > 3 files changed, 47 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/h264.c b/libavcodec/h264.c > index 1cbd4cb..1569ec8 100644 > --- a/libavcodec/h264.c > +++ b/libavcodec/h264.c > @@ -609,6 +609,8 @@ static int h264_init_context(AVCodecContext *avctx, > H264Context *h) > h->prev_frame_num= -1; > h->sei_fpa.frame_packing_arrangement_cancel_flag = -1; > h->has_afd = 0; > +h->a53_caption_size = 0; > +h->a53_caption = NULL; > > h->next_outputed_poc = INT_MIN; > for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) > @@ -879,6 +881,15 @@ static void decode_postinit(H264Context *h, int > setup_finished) > } > } > > +if (h->a53_caption) { > +AVFrameSideData *sd = > +av_frame_new_side_data(cur->f, AV_FRAME_DATA_A53_CC, > h->a53_caption_size); > +if (sd) > +memcpy(sd->data, h->a53_caption, h->a53_caption_size); > +av_freep(&h->a53_caption); > +h->a53_caption_size = 0; > +} > + > cur->mmco_reset = h->mmco_reset; > h->mmco_reset = 0; > > diff --git a/libavcodec/h264.h b/libavcodec/h264.h > index 7565e03..3aef49f 100644 > --- a/libavcodec/h264.h > +++ b/libavcodec/h264.h > @@ -784,6 +784,8 @@ typedef struct H264Context { > uint8_t afd; > int has_afd; > > +int a53_caption_size; > +uint8_t *a53_caption; > > // Timestamp stuff > int sei_buffering_period_present; ///< Buffering period SEI flag > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c > index b6ec5c7..5c6fcc0 100644 > --- a/libavcodec/h264_sei.c > +++ b/libavcodec/h264_sei.c > @@ -111,7 +111,7 @@ static int decode_picture_timing(H264Context *h) > static int decode_user_data_itu_t_t35(H264Context *h, int size) > { > uint32_t user_identifier; > -int dtg_active_format; > +int dtg_active_format, cc_count, user_data_type_code; > > if (size < 7) > return -1; > @@ -143,6 +143,39 @@ FF_ENABLE_DEPRECATION_WARNINGS > skip_bits(&h->gb, 6); > } > break; > +case 0x47413934: // "GA94" closed captions > Pardon my ignorance, but is this endian safe? 0x47413934 is "GA94" on big-endian architectures, won't it be 0x34394147 on little-endian? > +if (size < 3) > +return AVERROR(EINVAL); > +user_data_type_code = get_bits(&h->gb, 8); > +if (user_data_type_code == 0x3) { > +skip_bits(&h->gb, 1); > +if (get_bits(&h->gb, 1)) { > +skip_bits(&h->gb, 1); > +cc_count = get_bits(&h->gb, 5); > +skip_bits(&h->gb, 8); > +size -= 2; > +if (cc_count && size >= cc_count*3) { > +int i; > +uint8_t *tmp; > +if ((int64_t)h->a53_caption_size + > (int64_t)cc_count*3 > INT_MAX) > +return AVERROR(EINVAL); > + > +// Allow merging of the cc data from two fields > +tmp = av_realloc(h->a53_caption, > h->a53_caption_size + cc_count*3); > +if (!tmp) > +return AVERROR(ENOMEM); > +h->a53_caption = tmp; > +for (i = 0; i < cc_count; i++) { > +h->a53_caption[h->a53_caption_size++] = > get_bits(&h->gb, 8); > +h->a53_caption[h->a53_caption_size++] = > get_bits(&h->gb, 8); > +h->a53_caption[h->a53_caption_size++] = > get_bits(&h->gb, 8); > +} > + > +skip_bits(&h->gb, 8); > +} > +} > +} > +break; > default: > skip_bits(&h->gb, size * 8); > break; > -- > 1.9.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] swscale: implement YA8 output
On 7/2/15, Michael Niedermayer wrote: > On Wed, Jul 01, 2015 at 07:41:33PM +, Paul B Mahol wrote: >> Signed-off-by: Paul B Mahol >> --- >> >> Are _1_c and _2_c actually needed? > > I think they are not needed (they are just optimizations), you can > try by just scalig horizontally and bilinearly upscaling if it works > either way patch LGTM There is off by one somewhere in alpha scaling. How to reproduce: ffmpeg -f lavfi -i smptehdbars -f lavfi -i smptehdbars -lavfi alphamerge -c:v rawvideo -frames 1 yuva420p.nut ffmpeg -i yuva420p.nut -vf format=ya8 ya8.png ffmpeg -i ya8.png -vf extractplanes=a aya8.yuv ffmpeg -i yuva420p.nut -vf extractplanes=a ayuva420p.yuv Above two should be same, but they are not. Compare last two yuvs with hex editor like dhex: dhex aya8.yuv ayuva420p.yuv I will push patch anyway as this seems to be unrelated to ya8 output. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] wavpack: limit extra_bits to 32 and use get_bits_long
More than 32 bits can't be stored in an integer and get_bits should not be used with more than 25 bits. Signed-off-by: Andreas Cadhalpun --- libavcodec/wavpack.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index d91b66c..554367b 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -271,7 +271,7 @@ static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, if (s->got_extra_bits && get_bits_left(&s->gb_extra_bits) >= s->extra_bits) { -S |= get_bits(&s->gb_extra_bits, s->extra_bits); +S |= get_bits_long(&s->gb_extra_bits, s->extra_bits); *crc = *crc * 9 + (S & 0x) * 3 + ((unsigned)S >> 16); } } @@ -835,7 +835,11 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, continue; } bytestream2_get_buffer(&gb, val, 4); -if (val[0]) { +if (val[0] > 32) { +av_log(avctx, AV_LOG_ERROR, + "Invalid INT32INFO, extra_bits = %d (> 32)\n", val[0]); +continue; +} else if (val[0]) { s->extra_bits = val[0]; } else if (val[1]) { s->shift = val[1]; -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Patch for x86 YUV->BGR32 using MMX
On Thu, Jul 02, 2015 at 11:02:34AM -0700, Kevin Coyle wrote: > Hi all, > > Attached is a patch to convert YUV->BGR32 using MMX. > > Thanks. theres a problem in the alpha plane with the code try: ./ffplay lena.pnm -vf format=yuva444p,shuffleplanes=3:3:3:0,format=yuva422p,scale=260:260,format=rgba,scale=240:240,format=gbrap,shuffleplanes=3:3:3:0 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB You can kill me, but you cannot change the truth. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCHv3] avcodec: Add support for Closed Caption export in h264
--- libavcodec/h264.c | 11 +++ libavcodec/h264.h | 2 ++ libavcodec/h264_sei.c | 35 ++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 1cbd4cb..1569ec8 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -609,6 +609,8 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h) h->prev_frame_num= -1; h->sei_fpa.frame_packing_arrangement_cancel_flag = -1; h->has_afd = 0; +h->a53_caption_size = 0; +h->a53_caption = NULL; h->next_outputed_poc = INT_MIN; for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) @@ -879,6 +881,15 @@ static void decode_postinit(H264Context *h, int setup_finished) } } +if (h->a53_caption) { +AVFrameSideData *sd = +av_frame_new_side_data(cur->f, AV_FRAME_DATA_A53_CC, h->a53_caption_size); +if (sd) +memcpy(sd->data, h->a53_caption, h->a53_caption_size); +av_freep(&h->a53_caption); +h->a53_caption_size = 0; +} + cur->mmco_reset = h->mmco_reset; h->mmco_reset = 0; diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 7565e03..3aef49f 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -784,6 +784,8 @@ typedef struct H264Context { uint8_t afd; int has_afd; +int a53_caption_size; +uint8_t *a53_caption; // Timestamp stuff int sei_buffering_period_present; ///< Buffering period SEI flag diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index b6ec5c7..5c6fcc0 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -111,7 +111,7 @@ static int decode_picture_timing(H264Context *h) static int decode_user_data_itu_t_t35(H264Context *h, int size) { uint32_t user_identifier; -int dtg_active_format; +int dtg_active_format, cc_count, user_data_type_code; if (size < 7) return -1; @@ -143,6 +143,39 @@ FF_ENABLE_DEPRECATION_WARNINGS skip_bits(&h->gb, 6); } break; +case 0x47413934: // "GA94" closed captions +if (size < 3) +return AVERROR(EINVAL); +user_data_type_code = get_bits(&h->gb, 8); +if (user_data_type_code == 0x3) { +skip_bits(&h->gb, 1); +if (get_bits(&h->gb, 1)) { +skip_bits(&h->gb, 1); +cc_count = get_bits(&h->gb, 5); +skip_bits(&h->gb, 8); +size -= 2; +if (cc_count && size >= cc_count*3) { +int i; +uint8_t *tmp; +if ((int64_t)h->a53_caption_size + (int64_t)cc_count*3 > INT_MAX) +return AVERROR(EINVAL); + +// Allow merging of the cc data from two fields +tmp = av_realloc(h->a53_caption, h->a53_caption_size + cc_count*3); +if (!tmp) +return AVERROR(ENOMEM); +h->a53_caption = tmp; +for (i = 0; i < cc_count; i++) { +h->a53_caption[h->a53_caption_size++] = get_bits(&h->gb, 8); +h->a53_caption[h->a53_caption_size++] = get_bits(&h->gb, 8); +h->a53_caption[h->a53_caption_size++] = get_bits(&h->gb, 8); +} + +skip_bits(&h->gb, 8); +} +} +} +break; default: skip_bits(&h->gb, size * 8); break; -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 6/8] aaccoder: add a new perceptual noise substitution implementation
This commit finalizes the PNS implementation previously added to the encoder by moving it to a seperate function search_for_pns() and thus making it coder-generic. This new implementation makes use of the spread field of the psy bands and the lambda quality feedback paremeter. The spread of the spectrum in a band prevents PNS from being used excessively and thus preserve more phase information in high frequencies. The lambda parameter allows the number of PNS-marked bands to vary based on the lambda parameter and the amount of bits available, making better choices on which bands are to be marked as noise. Comparisons with the previous PNS implementation can be found here: https://trac.ffmpeg.org/attachment/wiki/Encode/AAC/ This is V2 of the patch, the changes from the previous version being that this version uses the new band->spread metric from aacpsy and normalizes the energy using the group size. These changes were suggested by Claudio Freire on the mailing list. Another change is the use of lambda to alter the frequency threshold. This change makes the actual threshold frequencies vary between +-2Khz of what's specified, depending on frame encoding performance. --- libavcodec/aaccoder.c | 52 ++- libavcodec/aacenc.c | 6 ++ libavcodec/aacenc.h | 1 + 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 8695a88..95782fc 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -41,7 +41,16 @@ #include "aactab.h" /** Frequency in Hz for lower limit of noise substitution **/ -#define NOISE_LOW_LIMIT 4000 +#define NOISE_LOW_LIMIT 4500 + +/* Energy spread threshold value below which no PNS is used, this corresponds to + * typically around 17Khz, after which PNS usage decays ending at 19Khz */ +#define NOISE_SPREAD_THRESHOLD 0.5f + +/* This constant gets divided by lambda to return ~1.65 which when multiplied + * by the band->threshold and compared to band->energy is the boundary between + * excessive PNS and little PNS usage. */ +#define NOISE_LAMBDA_NUMERATOR 252.1f /** Total number of usable codebooks **/ #define CB_TOT 12 @@ -1132,6 +1141,43 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, sce->sf_idx[(w+w2)*16+g] = sce->sf_idx[w*16+g]; } +static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce, + const float lambda) +{ +int start = 0, w, w2, g; +const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f; +const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/120.f); +const float thr_mult = NOISE_LAMBDA_NUMERATOR/lambda; + +/* Coders !twoloop don't reset the band_types */ +for (w = 0; w < 128; w++) +if (sce->band_type[w] == NOISE_BT) +sce->band_type[w] = 0; + +for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { +start = 0; +for (g = 0; g < sce->ics.num_swb; g++) { +if (start*freq_mult > NOISE_LOW_LIMIT*(lambda/170.0f)) { +float energy = 0.0f, threshold = 0.0f, spread = 0.0f; +for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { +FFPsyBand *band = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g]; +energy += band->energy; +threshold += band->threshold; +spread += band->spread; +} +if (spread > spread_threshold*sce->ics.group_len[w] && +((sce->zeroes[w*16+g] && energy >= threshold) || +energy < threshold*thr_mult*sce->ics.group_len[w])) { +sce->band_type[w*16+g] = NOISE_BT; +sce->pns_ener[w*16+g] = energy / sce->ics.group_len[w]; +sce->zeroes[w*16+g] = 0; +} +} +start += sce->ics.swb_sizes[g]; +} +} +} + static void search_for_ms(AACEncContext *s, ChannelElement *cpe, const float lambda) { @@ -1200,6 +1246,7 @@ AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = { encode_window_bands_info, quantize_and_encode_band, set_special_band_scalefactors, +search_for_pns, search_for_ms, }, [AAC_CODER_ANMR] = { @@ -1207,6 +1254,7 @@ AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = { encode_window_bands_info, quantize_and_encode_band, set_special_band_scalefactors, +search_for_pns, search_for_ms, }, [AAC_CODER_TWOLOOP] = { @@ -1214,6 +1262,7 @@ AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = { codebook_trellis_rate, quantize_and_encode_band, set_special_band_scalefactors, +search_for_pns, search_for_ms, }, [AAC_CODER_FAST] = { @@ -1221,6 +1270
[FFmpeg-devel] [PATCH v2 4/8] aacenc: reset marked IS and M/S bands upon frame encoding
This commit resets any bands marked as M/S or IS upon encoding a frame. This is needed because the arrays may contain some residual information upon allocation on startup and because there isn't any mechanism to reset the arrays once the frame has been encoded. --- libavcodec/aacenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 3a512ff..05a8162 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -617,6 +617,8 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, tag = s->chan_map[i+1]; chans= tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; +memset(cpe->is_mask, 0, sizeof(cpe->is_mask)); +memset(cpe->ms_mask, 0, sizeof(cpe->ms_mask)); put_bits(&s->pb, 3, tag); put_bits(&s->pb, 4, chan_el_counter[tag]++); for (ch = 0; ch < chans; ch++) -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 8/8] aacenc: implement Intensity Stereo encoding support
This commit implements intensity stereo coding support to the native aac encoder. This is a way to increase the efficiency of the encoder by zeroing the right channel's spectral coefficients (in a channel pair) and rederiving them in the decoder using information from the scalefactor indices of special band types. This commit confomrs to the official ISO 13818-7 specifications, although due to their ambiguity certain deviations have been taken to ensure maximum sound quality. This commit has been extensively tested and has shown to not result in audiable audio artifacts unless in extreme cases. This commit also adds an option, aac_is, which has the value of 0 by default. Intensity Stereo is part of the scalable aac profile and is thus non-default. The way IS coding works is that it rederives the right channel's spectral coefficients from the left channel via the scalefactor index values left in the right channel. Since an entire band's spectral coefficients do not need to be coded, the encoder's efficiency jumps up and it unzeroes some high frequency values which it previously did not have enough bits to encode. That way less information is lost than the information lost by rederiving the spectral coefficients with some error. This is why the filesize of files encoded with IS do not decrease significantly. Users wishing that IS coding should reduce filesize are expected to reduce their encoding bitrates appropriately. This is V2 of the commit. The old version did not mark ms_mask as 0 since M/S and IS coding are incompactible, which resulted in distortions with M/S coding enabled. This version also improves phase detection by measuring it for every spectral coefficient in the band and using a simple majority rule to determine whether the coefficients are in or out of phase. Also, the energy values per spectral coefficient were changed as to reflect the official specifications. --- libavcodec/aaccoder.c | 107 +- libavcodec/aacenc.c | 11 +- libavcodec/aacenc.h | 2 + 3 files changed, 117 insertions(+), 3 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 95782fc..5bdba46 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -52,6 +52,9 @@ * excessive PNS and little PNS usage. */ #define NOISE_LAMBDA_NUMERATOR 252.1f +/** Frequency in Hz for lower limit of intensity stereo **/ +#define INT_STEREO_LOW_LIMIT 6100 + /** Total number of usable codebooks **/ #define CB_TOT 12 @@ -1178,6 +1181,104 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne } } +static void search_for_is(AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe, + const float lambda) +{ +float IS[128]; +float *L34 = s->scoefs + 128*0, *R34 = s->scoefs + 128*1; +float *I34 = s->scoefs + 128*2; +SingleChannelElement *sce0 = &cpe->ch[0]; +SingleChannelElement *sce1 = &cpe->ch[1]; +int start = 0, count = 0, i, w, w2, g; +const float freq_mult = avctx->sample_rate/(1024.0f/sce0->ics.num_windows)/2.0f; + +for (w = 0; w < 128; w++) +if (sce1->band_type[w] >= INTENSITY_BT2) +sce1->band_type[w] = 0; + +if (!cpe->common_window) +return; +for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) { +start = 0; +for (g = 0; g < sce0->ics.num_swb; g++) { +if (start*freq_mult > INT_STEREO_LOW_LIMIT*(lambda/170.0f) && +cpe->ch[0].band_type[w*16+g] != NOISE_BT && !cpe->ch[0].zeroes[w*16+g] && +cpe->ch[1].band_type[w*16+g] != NOISE_BT && !cpe->ch[1].zeroes[w*16+g]) { +int phase = 0; +float ener0 = 0.0f, ener1 = 0.0f, ener01 = 0.0f; +float dist1 = 0.0f, dist2 = 0.0f; +for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { +for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { +float coef0 = sce0->pcoeffs[start+(w+w2)*128+i]; +float coef1 = sce1->pcoeffs[start+(w+w2)*128+i]; +phase += coef0*coef1 >= 0.0f ? 1 : -1; +ener0 += coef0*coef0; +ener1 += coef1*coef1; +ener01 += (coef0 + coef1)*(coef0 + coef1); +} +} +if (!phase) { /* Too much phase difference between channels */ +start += sce0->ics.swb_sizes[g]; +continue; +} +phase = av_clip(phase, -1, 1); +for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { +FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g]; +FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g]; +int is_band_type, is_sf_idx = FFMAX(1, sce0->sf_idx[(w+w2)*16
[FFmpeg-devel] [PATCH v2 5/8] aacenc: use the new function for setting special band scalefactor indices
This commit enables the function added with commit 7c10b87 and uses that new function for setting any special scalefactor indices. This commit does not change the behaviour of the encoder since no bands are being marked as either NOISE_BT(due to the previous PNS implementation removed in the previous commit) or INTENSITY_BT2/INTENSITY_BT. --- libavcodec/aaccoder.c | 4 libavcodec/aacenc.c | 3 +++ libavcodec/aacenc.h | 1 + 3 files changed, 8 insertions(+) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 33cbe7b..8695a88 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -1199,24 +1199,28 @@ AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = { search_for_quantizers_faac, encode_window_bands_info, quantize_and_encode_band, +set_special_band_scalefactors, search_for_ms, }, [AAC_CODER_ANMR] = { search_for_quantizers_anmr, encode_window_bands_info, quantize_and_encode_band, +set_special_band_scalefactors, search_for_ms, }, [AAC_CODER_TWOLOOP] = { search_for_quantizers_twoloop, codebook_trellis_rate, quantize_and_encode_band, +set_special_band_scalefactors, search_for_ms, }, [AAC_CODER_FAST] = { search_for_quantizers_fast, encode_window_bands_info, quantize_and_encode_band, +set_special_band_scalefactors, search_for_ms, }, }; diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 05a8162..3854066 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -652,6 +652,9 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, s->coder->search_for_ms(s, cpe, s->lambda); } } +if (s->coder->set_special_band_scalefactors) +for (ch = 0; ch < chans; ch++) +s->coder->set_special_band_scalefactors(s, &cpe->ch[ch]); adjust_frame_information(cpe, chans); if (chans == 2) { put_bits(&s->pb, 1, cpe->common_window); diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h index 7c1f277..cc1b06a 100644 --- a/libavcodec/aacenc.h +++ b/libavcodec/aacenc.h @@ -54,6 +54,7 @@ typedef struct AACCoefficientsEncoder { int win, int group_len, const float lambda); void (*quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, int size, int scale_idx, int cb, const float lambda); +void (*set_special_band_scalefactors)(struct AACEncContext *s, SingleChannelElement *sce); void (*search_for_ms)(struct AACEncContext *s, ChannelElement *cpe, const float lambda); } AACCoefficientsEncoder; -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 7/8] aacenc: add support for coding of IS spectral coefficients
This commit adds support for the coding of intensity stereo spectral coefficients. It also fixes the Mid/Side coding of band_types higher than RESERVED_BT (M/S must not be applied to their spectral coefficients, but marking M/S as present in encode_ms_info() is okay). Much of the changes here were taken from the decoder and inverted. This commit does not change the functionality of the decoder as the previous patch in this series zeroes ms_mask and is_mask. Reviewed-by: Claudio Freire --- libavcodec/aacenc.c | 37 +++-- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index f7325d4..3e5ac72 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -312,19 +312,26 @@ static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe) static void adjust_frame_information(ChannelElement *cpe, int chans) { int i, w, w2, g, ch; -int start, maxsfb, cmaxsfb; +int maxsfb, cmaxsfb; +IndividualChannelStream *ics; -for (ch = 0; ch < chans; ch++) { -IndividualChannelStream *ics = &cpe->ch[ch].ics; -start = 0; -maxsfb = 0; -cpe->ch[ch].pulse.num_pulse = 0; +if (cpe->common_window) { +ics = &cpe->ch[0].ics; for (w = 0; w < ics->num_windows; w += ics->group_len[w]) { -for (w2 = 0; w2 < ics->group_len[w]; w2++) { -start = (w+w2) * 128; +for (w2 = 0; w2 < ics->group_len[w]; w2++) { +int start = (w+w2) * 128; for (g = 0; g < ics->num_swb; g++) { -//apply M/S -if (cpe->common_window && !ch && cpe->ms_mask[w*16 + g]) { +//apply Intensity stereo coeffs transformation +if (cpe->is_mask[w*16 + g]) { +int p = -1 + 2 * (cpe->ch[1].band_type[w*16+g] - 14); +float scale = cpe->ch[0].is_ener[w*16+g]; +for (i = 0; i < ics->swb_sizes[g]; i++) { +cpe->ch[0].coeffs[start+i] = (cpe->ch[0].pcoeffs[start+i] + p*cpe->ch[1].pcoeffs[start+i]) * scale; +cpe->ch[1].coeffs[start+i] = 0.0f; +} +} else if (cpe->ms_mask[w*16 + g] && + cpe->ch[0].band_type[w*16 + g] < NOISE_BT && + cpe->ch[1].band_type[w*16 + g] < NOISE_BT) { for (i = 0; i < ics->swb_sizes[g]; i++) { cpe->ch[0].coeffs[start+i] = (cpe->ch[0].pcoeffs[start+i] + cpe->ch[1].pcoeffs[start+i]) * 0.5f; cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].pcoeffs[start+i]; @@ -332,6 +339,16 @@ static void adjust_frame_information(ChannelElement *cpe, int chans) } start += ics->swb_sizes[g]; } +} +} +} + +for (ch = 0; ch < chans; ch++) { +IndividualChannelStream *ics = &cpe->ch[ch].ics; +maxsfb = 0; +cpe->ch[ch].pulse.num_pulse = 0; +for (w = 0; w < ics->num_windows; w += ics->group_len[w]) { +for (w2 = 0; w2 < ics->group_len[w]; w2++) { for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--) ; maxsfb = FFMAX(maxsfb, cmaxsfb); -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 2/8] aaccoder: remove previous PNS implementation from twoloop
This commit undoes commit c5d4f87e8427c0952278ec247fa8ab1e6e52 and removes PNS band marking from the twoloop coder, which has been reimplemented in a better way in this series of patches. --- libavcodec/aaccoder.c | 29 +++-- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index cd996b2..3fcc8b4 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -792,11 +792,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, { int start = 0, i, w, w2, g; int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels * (lambda / 120.f); -const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f; float dists[128] = { 0 }, uplims[128] = { 0 }; float maxvals[128]; -int noise_sf[128] = { 0 }; -int fflag, minscaler, minscaler_n; +int fflag, minscaler; int its = 0; int allz = 0; float minthr = INFINITY; @@ -807,13 +805,12 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, //XXX: some heuristic to determine initial quantizers will reduce search time //determine zero bands and upper limits for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { -start = 0; for (g = 0; g < sce->ics.num_swb; g++) { int nz = 0; float uplim = 0.0f, energy = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; -uplim += band->threshold; +uplim += band->threshold; energy += band->energy; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; @@ -822,18 +819,10 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, nz = 1; } uplims[w*16+g] = uplim *512; -if (s->options.pns && start*freq_mult > NOISE_LOW_LIMIT && energy < uplim * 1.2f) { -noise_sf[w*16+g] = av_clip(4+FFMIN(log2f(energy)*2,255), -100, 155); -sce->band_type[w*16+g] = NOISE_BT; -nz= 1; -} else { /** Band type will be determined by the twoloop algorithm */ -sce->band_type[w*16+g] = 0; -} sce->zeroes[w*16+g] = !nz; if (nz) minthr = FFMIN(minthr, uplim); allz |= nz; -start += sce->ics.swb_sizes[g]; } } for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { @@ -864,7 +853,6 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, do { int tbits, qstep; minscaler = sce->sf_idx[0]; -minscaler_n = sce->sf_idx[0]; //inner loop - quantize spectrum to fit into given number of bits qstep = its ? 1 : 32; do { @@ -879,11 +867,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, int cb; float dist = 0.0f; -if (sce->band_type[w*16+g] == NOISE_BT) { -minscaler_n = FFMIN(minscaler_n, noise_sf[w*16+g]); -start += sce->ics.swb_sizes[g]; -continue; -} else if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) { +if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) { start += sce->ics.swb_sizes[g]; continue; } @@ -927,16 +911,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, fflag = 0; minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF); -for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) -for (g = 0; g < sce->ics.num_swb; g++) -if (sce->band_type[w*16+g] == NOISE_BT) -sce->sf_idx[w*16+g] = av_clip(noise_sf[w*16+g], minscaler_n, minscaler_n + SCALE_MAX_DIFF); - for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { int prevsc = sce->sf_idx[w*16+g]; -if (sce->band_type[w*16+g] == NOISE_BT) -continue; if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) { if (find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]-1)) sce->sf_idx[w*16+g]--; -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 3/8] aaccoder: fix M/S coding
There were some mistakes in the code for M/S stereo, this commit fixes them. The start variable was not being reset for every window and every access to the coefficients was incorrect as well. This fixes that by properly addressing the coefficients using both windows and setting the start on every window to zero. --- libavcodec/aaccoder.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 3fcc8b4..33cbe7b 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -1143,6 +1143,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe, if (!cpe->common_window) return; for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) { +start = 0; for (g = 0; g < sce0->ics.num_swb; g++) { if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) { float dist1 = 0.0f, dist2 = 0.0f; @@ -1152,22 +1153,22 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe, float minthr = FFMIN(band0->threshold, band1->threshold); float maxthr = FFMAX(band0->threshold, band1->threshold); for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { -M[i] = (sce0->pcoeffs[start+w2*128+i] - + sce1->pcoeffs[start+w2*128+i]) * 0.5; +M[i] = (sce0->pcoeffs[start+(w+w2)*128+i] + + sce1->pcoeffs[start+(w+w2)*128+i]) * 0.5; S[i] = M[i] - - sce1->pcoeffs[start+w2*128+i]; + - sce1->pcoeffs[start+(w+w2)*128+i]; } -abs_pow34_v(L34, sce0->coeffs+start+w2*128, sce0->ics.swb_sizes[g]); -abs_pow34_v(R34, sce1->coeffs+start+w2*128, sce0->ics.swb_sizes[g]); +abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); +abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]); abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]); -dist1 += quantize_band_cost(s, sce0->coeffs + start + w2*128, +dist1 += quantize_band_cost(s, sce0->coeffs + start + (w+w2)*128, L34, sce0->ics.swb_sizes[g], sce0->sf_idx[(w+w2)*16+g], sce0->band_type[(w+w2)*16+g], lambda / band0->threshold, INFINITY, NULL); -dist1 += quantize_band_cost(s, sce1->coeffs + start + w2*128, +dist1 += quantize_band_cost(s, sce1->coeffs + start + (w+w2)*128, R34, sce1->ics.swb_sizes[g], sce1->sf_idx[(w+w2)*16+g], -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 0/8] aac: Implement Intensity Stereo encoding support
This series of patches implements intensity stereo encoding support, reimplements perceptual noise substitution in a better way and fixes some mistakes in the M/S (Mid/Side) stereo marking. Currently, both IS and PNS are off by default, changeable via the options -aac_pns and -aac_is, respectively. Users and developers are welcome to test the options to increase the quality and efficiency of the encoder. The options do not increase filesize significantly (+-10 Kb per 3400Kb total filesize, 128kbps, reasonable activity in all frequency bands) but they offer a drastic increase in quality. Therefore, in general, to achieve the same quality as without IS or PNS users need to reduce their bitrates and therefore decrease filesizes of encoded files. The perceptual noise substitution is supposed to be on for all files encoded via the AAC LC profile and feedback and suggestions would go a long way in making this option be 'on' by default, making everyone benefit from increased encoder quality. It should be noted that the benefits of both options decay as the bitrates increase. PNS usage becomes non-existant at around 200kbps and IS could reduce quality at very high bitrates. This is V2 of the patch, notable changes from V1 are: * Change the way aacpsy sets the band spread value * Improve PNS energy calculations * Disable M/S coding for bands marked to use IS * Improve phase detection for IS bands * Improve energy calculations for IS spectral coefficients * Make the thresholds of both IS and PNS dynamic Rostislav Pehlivanov (8): aacpsy: use a different metric for the spread of a band aaccoder: remove previous PNS implementation from twoloop aaccoder: fix M/S coding aacenc: reset marked IS and M/S bands upon frame encoding aacenc: use the new function for setting special band scalefactor indices aaccoder: add a new perceptual noise substitution implementation aacenc: add support for coding of IS spectral coefficients aacenc: implement Intensity Stereo encoding support libavcodec/aaccoder.c | 207 +- libavcodec/aacenc.c | 59 +++--- libavcodec/aacenc.h | 4 + libavcodec/aacpsy.c | 2 +- 4 files changed, 224 insertions(+), 48 deletions(-) -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 1/8] aacpsy: use a different metric for the spread of a band
This commit modifies 02dbed6 to use band->active_lines to better gauge how much information is contained within a single band and thus allow the perceptual noise subsitution to more accurately determine which bands to code as noise. The spread[w+g] used before this patch behaved more like a low-pass filter for PNS band_types, which could mistakingly mark some low frequency bands as noise. Reviewed-by: Claudio Freire --- libavcodec/aacpsy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 78232d4..b16f6b9 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -787,7 +787,7 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel, psy_band->threshold = band->thr; psy_band->energy= band->energy; -psy_band->spread= spread_en[w+g]; +psy_band->spread= band->active_lines * 2.0f / band_sizes[g]; } } -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Patch for x86 YUV->BGR32 using MMX
Hi all, Attached is a patch to convert YUV->BGR32 using MMX. Thanks. From a5c81a13c2d1dc7406d9fc3579d8df94627d70c5 Mon Sep 17 00:00:00 2001 From: Kevin Coyle Date: Thu, 2 Jul 2015 10:46:29 -0700 Subject: [PATCH] Add yuv->bgr32 mmx support --- libswscale/x86/swscale_template.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 36a606c..5d24f4c 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -399,6 +399,35 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter, } } +static void RENAME(yuv2bgr32_X)(SwsContext *c, const int16_t *lumFilter, +const int16_t **lumSrc, int lumFilterSize, +const int16_t *chrFilter, const int16_t **chrUSrc, +const int16_t **chrVSrc, +int chrFilterSize, const int16_t **alpSrc, +uint8_t *dest, int dstW, int dstY) +{ +x86_reg dummy=0; +x86_reg dstW_reg = dstW; +x86_reg uv_off = c->uv_offx2; + +if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { +YSCALEYUV2PACKEDX +YSCALEYUV2RGBX +YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7) +"psraw$3, %%mm1 \n\t" +"psraw$3, %%mm7 \n\t" +"packuswb %%mm7, %%mm1 \n\t" +WRITEBGR32(%4, "%5", %%REGa, %%mm5, %%mm4, %%mm2, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) +YSCALEYUV2PACKEDX_END +} else { +YSCALEYUV2PACKEDX +YSCALEYUV2RGBX +"pcmpeqd %%mm7, %%mm7 \n\t" +WRITEBGR32(%4, "%5", %%REGa, %%mm5, %%mm4, %%mm2, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) +YSCALEYUV2PACKEDX_END +} +} + #define REAL_WRITERGB16(dst, dstw, index) \ "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\ @@ -1491,6 +1520,7 @@ static av_cold void RENAME(sws_init_swscale)(SwsContext *c) if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; +case AV_PIX_FMT_BGR32: c->yuv2packedX = RENAME(yuv2bgr32_X); break; #if HAVE_6REGS case AV_PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break; #endif -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Patch to correct QSV encoder's quality presets set
On Thu, Jul 02, 2015 at 07:45:42PM +0300, Ivan Uskov wrote: > Hello All, > > There is a patch attached to more correct map QSV encoder quality presets. > Please review. > > -- > Best regards, > Ivan mailto:ivan.us...@nablet.com > qsvenc_h264.c | 12 > 1 file changed, 8 insertions(+), 4 deletions(-) > 130dc58b5cbe7d732d42a066dd935af5eac65a5d > 0001-The-set-of-performance-presets-has-been-corrected-to.patch > From 022747bfaad5e4a7ca9f27a03cca84d940426b9c Mon Sep 17 00:00:00 2001 > From: Ivan Uskov > Date: Thu, 2 Jul 2015 19:09:12 +0300 > Subject: [PATCH] The set of performance presets has been corrected to match > with MFX library constants. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Patch to correct QSV encoder's quality presets set
Hello All, There is a patch attached to more correct map QSV encoder quality presets. Please review. -- Best regards, Ivan mailto:ivan.us...@nablet.com 0001-The-set-of-performance-presets-has-been-corrected-to.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: use AVFILTER_DEFINE_CLASS()
On Thu, Jul 02, 2015 at 09:52:02AM +, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > libavfilter/af_bs2b.c | 9 ++--- > libavfilter/vf_cover_rect.c| 8 +--- > libavfilter/vf_find_rect.c | 12 +++- > libavfilter/vf_framepack.c | 9 ++--- > libavfilter/vf_shuffleplanes.c | 7 +-- > 5 files changed, 9 insertions(+), 36 deletions(-) LGTM thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] api-seek-test: first version
Works only with video stream. --- tests/api/Makefile| 1 + tests/api/api-seek-test.c | 197 ++ tests/fate/api.mak| 4 + tests/ref/fate/api-seek | 147 ++ 4 files changed, 349 insertions(+) create mode 100644 tests/api/api-seek-test.c create mode 100644 tests/ref/fate/api-seek diff --git a/tests/api/Makefile b/tests/api/Makefile index 704987e..59cbc7c 100644 --- a/tests/api/Makefile +++ b/tests/api/Makefile @@ -1,5 +1,6 @@ APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264 +APITESTPROGS-yes += api-seek APITESTPROGS += $(APITESTPROGS-yes) APITESTOBJS := $(APITESTOBJS:%=$(APITESTSDIR)%) $(APITESTPROGS:%=$(APITESTSDIR)/%-test.o) diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c new file mode 100644 index 000..9f8bad9 --- /dev/null +++ b/tests/api/api-seek-test.c @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2015 Ludmila Glinskih + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * Seek test. + */ + +#include "libavutil/adler32.h" +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +#include "libavutil/imgutils.h" + +static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream, +AVCodecContext *ctx, AVFrame *fr, uint64_t ts_start, uint64_t ts_end) +{ +int number_of_written_bytes; +int got_frame = 0; +int result; +int end_of_stream = 0; +int byte_buffer_size; +uint8_t *byte_buffer; +AVPacket pkt; + +byte_buffer_size = av_image_get_buffer_size(ctx->pix_fmt, ctx->width, ctx->height, 16); +byte_buffer = av_malloc(byte_buffer_size); +if (!byte_buffer) { +av_log(NULL, AV_LOG_ERROR, "Can't allocate buffer\n"); +return AVERROR(ENOMEM); +} + +result = av_seek_frame(fmt_ctx, video_stream, ts_start, AVSEEK_FLAG_ANY); +printf("Seeking to %"PRId64", computing crc for frames with pts < %"PRId64"\n", ts_start, ts_end); +if (result < 0) { +av_log(NULL, AV_LOG_ERROR, "Error in seeking\n"); +return result; +} +avcodec_flush_buffers(ctx); + +av_init_packet(&pkt); +do { +if (!end_of_stream) +if (av_read_frame(fmt_ctx, &pkt) < 0) +end_of_stream = 1; +if (end_of_stream) +{ +pkt.data = NULL; +pkt.size = 0; +} +if (pkt.stream_index == video_stream || end_of_stream) { +got_frame = 0; +if (pkt.pts == AV_NOPTS_VALUE) { +av_log(NULL, AV_LOG_ERROR, "Error: frames doesn't have pts values\n"); +return -1; +} +result = avcodec_decode_video2(ctx, fr, &got_frame, &pkt); +if (result < 0) { +av_log(NULL, AV_LOG_ERROR, "Error decoding frame\n"); +return result; +} +if (got_frame) { +number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size, +(const uint8_t* const *)fr->data, (const int*) fr->linesize, +ctx->pix_fmt, ctx->width, ctx->height, 1); +if (number_of_written_bytes < 0) { +av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n"); +return number_of_written_bytes; +} +if (fr->pkt_pts > ts_end) +break; +printf("%10"PRId64", 0x%08lx\n", fr->pkt_pts, av_adler32_update(0, (const uint8_t*)byte_buffer, +number_of_written_bytes)); +} +} +av_free_packet(&pkt); +av_init_packet(&pkt); +} while ((!end_of_stream || got_frame) && (fr->pkt_pts + av_frame_get_pkt_duration(fr) <= ts_end)); + +av_free_packet(&pkt); +av_freep(&b
Re: [FFmpeg-devel] extract mv data
The codec which is used is h264 . I didn't check the cmd-line tool yet , what option do I give ? --debug vismv ? Br Christoph -Original Message- From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Michael Niedermayer Sent: jeudi 2 juillet 2015 17:44 To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] extract mv data On Thu, Jul 02, 2015 at 03:29:20PM +, Stevens, Christoph (Christoph) wrote: > Dear ; > > I am trying to extract the mv data from an AVframe after calling > avcodec_decode_video2 , and tried the following Enabling the debug_mv > as well as debug on the AVCodecContext resulted in the deprecated struct > motion_val to stay empty 0x0 As well as an alternative approach via a call to > av_frame_get_side_data , of which an example can be found in the > /libavfilter/vf_codecView.h did result in an empty structure . > > I wonder why the above stays empty or nill , can anyone help me out > Thank you very much what codec is used ? not all codecs support extracting MV data also does it work with ffmpeg (the command line tool) ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] extract mv data
On Thu, Jul 02, 2015 at 03:29:20PM +, Stevens, Christoph (Christoph) wrote: > Dear ; > > I am trying to extract the mv data from an AVframe after calling > avcodec_decode_video2 , and tried the following > Enabling the debug_mv as well as debug on the AVCodecContext resulted in the > deprecated struct motion_val to stay empty 0x0 > As well as an alternative approach via a call to av_frame_get_side_data , of > which an example can be found in the /libavfilter/vf_codecView.h did result > in an empty structure . > > I wonder why the above stays empty or nill , can anyone help me out > Thank you very much what codec is used ? not all codecs support extracting MV data also does it work with ffmpeg (the command line tool) ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] swscale: implement YA8 output
On Wed, Jul 01, 2015 at 07:41:33PM +, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > > Are _1_c and _2_c actually needed? I think they are not needed (they are just optimizations), you can try by just scalig horizontally and bilinearly upscaling if it works either way patch LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Breaking DRM is a little like attempting to break through a door even though the window is wide open and the only thing in the house is a bunch of things you dont want and which you would get tomorrow for free anyway signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] extract mv data
Stevens, Christoph (Christoph alcatel-lucent.com> writes: > I am trying to extract the mv data from an AVframe Please read https://ffmpeg.org/contact.html (again), libav-user is the right mailing list for your question. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] extract mv data
Dear ; I am trying to extract the mv data from an AVframe after calling avcodec_decode_video2 , and tried the following Enabling the debug_mv as well as debug on the AVCodecContext resulted in the deprecated struct motion_val to stay empty 0x0 As well as an alternative approach via a call to av_frame_get_side_data , of which an example can be found in the /libavfilter/vf_codecView.h did result in an empty structure . I wonder why the above stays empty or nill , can anyone help me out Thank you very much Greetings Christoph ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Patch to enable QSV acceleration under linux platform
On Tue, Jun 30, 2015 at 08:20:21PM +0300, Ivan Uskov wrote: > Hello Michael, > > Thank you very much, there is fixed patch attached, please look. > > Tuesday, June 30, 2015, 7:21:53 PM, you wrote: > > MN> On Tue, Jun 30, 2015 at 06:28:08PM +0300, Ivan Uskov wrote: > >> Hello Michael, > >> > >> I'm sorry, what exactly documentation should be added regarding this > >> patch? As I can see there is no any standalone topic about QSV into > >> current /doc. Can modifications of Changelog be enough? > > MN> your patch adds comments like "translate MSDK error codes to ffmpeg error > codes" > MN> these should be in a seperate patch as they are unrelated > MN> to " enable QSV acceleration under linux platform" > > MN> sorry if i wasnt clear > > > > > -- > Best regards, > Ivanmailto:ivan.us...@nablet.com > qsv.c | 70 > + > qsv_internal.h | 17 + > 2 files changed, 86 insertions(+), 1 deletion(-) > ed333740da8f028305afc768d2a6d5814c06308d > 0001-Extending-QSV-MFX-session-initialization-for-linux-p.patch > From ee54c9a1280a31f7ed9e5406e31ddef4ecdb239a Mon Sep 17 00:00:00 2001 > From: Ivan Uskov > Date: Tue, 30 Jun 2015 20:13:09 +0300 > Subject: [PATCH] Extending QSV/MFX session initialization for linux platform, > where a display handle is required. Now ff_qsv_init_internal_session() is > able to find appropriate display handle under linux using VAAPI. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter/vf_mpdecimate: remove packed formats
Packed formats are not supported. Signed-off-by: Paul B Mahol --- libavfilter/vf_mpdecimate.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavfilter/vf_mpdecimate.c b/libavfilter/vf_mpdecimate.c index 7cc3254..25efacf 100644 --- a/libavfilter/vf_mpdecimate.c +++ b/libavfilter/vf_mpdecimate.c @@ -168,9 +168,6 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVA420P, -AV_PIX_FMT_GRAY8A, -AV_PIX_FMT_YA8, - AV_PIX_FMT_GBRP, AV_PIX_FMT_YUVA444P, -- 1.7.11.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter: use AVFILTER_DEFINE_CLASS()
Signed-off-by: Paul B Mahol --- libavfilter/af_bs2b.c | 9 ++--- libavfilter/vf_cover_rect.c| 8 +--- libavfilter/vf_find_rect.c | 12 +++- libavfilter/vf_framepack.c | 9 ++--- libavfilter/vf_shuffleplanes.c | 7 +-- 5 files changed, 9 insertions(+), 36 deletions(-) diff --git a/libavfilter/af_bs2b.c b/libavfilter/af_bs2b.c index 592fdec..54d52c5 100644 --- a/libavfilter/af_bs2b.c +++ b/libavfilter/af_bs2b.c @@ -47,7 +47,7 @@ typedef struct Bs2bContext { #define OFFSET(x) offsetof(Bs2bContext, x) #define A AV_OPT_FLAG_AUDIO_PARAM -static const AVOption options[] = { +static const AVOption bs2b_options[] = { { "profile", "Apply a pre-defined crossfeed level", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = BS2B_DEFAULT_CLEVEL }, 0, INT_MAX, A, "profile" }, { "default", "default profile", 0, AV_OPT_TYPE_CONST, { .i64 = BS2B_DEFAULT_CLEVEL }, 0, 0, A, "profile" }, @@ -60,12 +60,7 @@ static const AVOption options[] = { { NULL }, }; -static const AVClass bs2b_class = { -.class_name = "bs2b filter", -.item_name = av_default_item_name, -.option = options, -.version= LIBAVUTIL_VERSION_INT, -}; +AVFILTER_DEFINE_CLASS(bs2b); static av_cold int init(AVFilterContext *ctx) { diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c index c2020bb..5086a24 100644 --- a/libavfilter/vf_cover_rect.c +++ b/libavfilter/vf_cover_rect.c @@ -53,13 +53,7 @@ static const AVOption cover_rect_options[] = { { NULL } }; -static const AVClass cover_rect_class = { -.class_name = "cover_rect", -.item_name= av_default_item_name, -.option = cover_rect_options, -.version = LIBAVUTIL_VERSION_INT, -.category = AV_CLASS_CATEGORY_FILTER, -}; +AVFILTER_DEFINE_CLASS(cover_rect); static int query_formats(AVFilterContext *ctx) { diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c index a4631de..cb79f4a 100644 --- a/libavfilter/vf_find_rect.c +++ b/libavfilter/vf_find_rect.c @@ -45,7 +45,7 @@ typedef struct FOCContext { #define OFFSET(x) offsetof(FOCContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM -static const AVOption foc_options[] = { +static const AVOption find_rect_options[] = { { "object", "object bitmap filename", OFFSET(obj_filename), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS }, { "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_FLOAT, {.dbl = 0.5}, 0, 1.0, FLAGS }, { "mipmaps", "set mipmaps", OFFSET(mipmaps), AV_OPT_TYPE_INT, {.i64 = 3}, 1, MAX_MIPMAPS, FLAGS }, @@ -56,13 +56,7 @@ static const AVOption foc_options[] = { { NULL } }; -static const AVClass foc_class = { -.class_name = "find_rect", -.item_name= av_default_item_name, -.option = foc_options, -.version = LIBAVUTIL_VERSION_INT, -.category = AV_CLASS_CATEGORY_FILTER, -}; +AVFILTER_DEFINE_CLASS(find_rect); static int query_formats(AVFilterContext *ctx) { @@ -307,5 +301,5 @@ AVFilter ff_vf_find_rect = { .query_formats = query_formats, .inputs = foc_inputs, .outputs = foc_outputs, -.priv_class = &foc_class, +.priv_class = &find_rect_class, }; diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c index e9b9ed1..be85f85 100644 --- a/libavfilter/vf_framepack.c +++ b/libavfilter/vf_framepack.c @@ -315,7 +315,7 @@ static int request_frame(AVFilterLink *outlink) #define OFFSET(x) offsetof(FramepackContext, x) #define V AV_OPT_FLAG_VIDEO_PARAM -static const AVOption options[] = { +static const AVOption framepack_options[] = { { "format", "Frame pack output format", OFFSET(format), AV_OPT_TYPE_INT, { .i64 = AV_STEREO3D_SIDEBYSIDE }, 0, INT_MAX, .flags = V, .unit = "format" }, { "sbs", "Views are packed next to each other", 0, AV_OPT_TYPE_CONST, @@ -331,12 +331,7 @@ static const AVOption options[] = { { NULL }, }; -static const AVClass framepack_class = { -.class_name = "framepack", -.item_name = av_default_item_name, -.option = options, -.version= LIBAVUTIL_VERSION_INT, -}; +AVFILTER_DEFINE_CLASS(framepack); static const AVFilterPad framepack_inputs[] = { { diff --git a/libavfilter/vf_shuffleplanes.c b/libavfilter/vf_shuffleplanes.c index 80085cd..45698ec 100644 --- a/libavfilter/vf_shuffleplanes.c +++ b/libavfilter/vf_shuffleplanes.c @@ -134,12 +134,7 @@ static const AVOption shuffleplanes_options[] = { { NULL }, }; -static const AVClass shuffleplanes_class = { -.class_name = "shuffleplanes", -.item_name = av_default_item_name, -.option = shuffleplanes_options, -.version= LIBAVUTIL_VERSION_INT, -}; +AVFILTER_DEFINE_CLASS(shuffleplanes); static const AVFilterPad shuffleplanes_inputs[] = { { -- 1.7.11.2 ___ ffmpeg-devel